Hal Finkel | bcc0608 | 2014-09-07 22:58:14 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s |
| 2 | |
| 3 | // CHECK-LABEL: @test1 |
| 4 | int test1(int *a) { |
| 5 | // CHECK: %ptrint = ptrtoint |
| 6 | // CHECK: %maskedptr = and i64 %ptrint, 31 |
| 7 | // CHECK: %maskcond = icmp eq i64 %maskedptr, 0 |
| 8 | // CHECK: call void @llvm.assume(i1 %maskcond) |
| 9 | a = __builtin_assume_aligned(a, 32, 0ull); |
| 10 | return a[0]; |
| 11 | } |
| 12 | |
| 13 | // CHECK-LABEL: @test2 |
| 14 | int test2(int *a) { |
| 15 | // CHECK: %ptrint = ptrtoint |
| 16 | // CHECK: %maskedptr = and i64 %ptrint, 31 |
| 17 | // CHECK: %maskcond = icmp eq i64 %maskedptr, 0 |
| 18 | // CHECK: call void @llvm.assume(i1 %maskcond) |
| 19 | a = __builtin_assume_aligned(a, 32, 0); |
| 20 | return a[0]; |
| 21 | } |
| 22 | |
| 23 | // CHECK-LABEL: @test3 |
| 24 | int test3(int *a) { |
| 25 | // CHECK: %ptrint = ptrtoint |
| 26 | // CHECK: %maskedptr = and i64 %ptrint, 31 |
| 27 | // CHECK: %maskcond = icmp eq i64 %maskedptr, 0 |
| 28 | // CHECK: call void @llvm.assume(i1 %maskcond) |
| 29 | a = __builtin_assume_aligned(a, 32); |
| 30 | return a[0]; |
| 31 | } |
| 32 | |
| 33 | // CHECK-LABEL: @test4 |
| 34 | int test4(int *a, int b) { |
| 35 | // CHECK-DAG: %ptrint = ptrtoint |
| 36 | // CHECK-DAG: %conv = sext i32 |
| 37 | // CHECK: %offsetptr = sub i64 %ptrint, %conv |
| 38 | // CHECK: %maskedptr = and i64 %offsetptr, 31 |
| 39 | // CHECK: %maskcond = icmp eq i64 %maskedptr, 0 |
| 40 | // CHECK: call void @llvm.assume(i1 %maskcond) |
| 41 | a = __builtin_assume_aligned(a, 32, b); |
| 42 | return a[0]; |
| 43 | } |
| 44 | |