1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
4 // CHECK-LABEL: @test1(
6 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
7 // CHECK-NEXT: store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
8 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
9 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[TMP0]], i64 32, i64 0) ]
10 // CHECK-NEXT: store ptr [[TMP0]], ptr [[A_ADDR]], align 8
11 // CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[A_ADDR]], align 8
12 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 0
13 // CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
14 // CHECK-NEXT: ret i32 [[TMP4]]
17 a
= __builtin_assume_aligned(a
, 32, 0ull);
21 // CHECK-LABEL: @test2(
23 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
24 // CHECK-NEXT: store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
25 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
26 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[TMP0]], i64 32, i64 0) ]
27 // CHECK-NEXT: store ptr [[TMP0]], ptr [[A_ADDR]], align 8
28 // CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[A_ADDR]], align 8
29 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 0
30 // CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
31 // CHECK-NEXT: ret i32 [[TMP4]]
34 a
= __builtin_assume_aligned(a
, 32, 0);
38 // CHECK-LABEL: @test3(
40 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
41 // CHECK-NEXT: store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
42 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
43 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[TMP0]], i64 32) ]
44 // CHECK-NEXT: store ptr [[TMP0]], ptr [[A_ADDR]], align 8
45 // CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[A_ADDR]], align 8
46 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 0
47 // CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
48 // CHECK-NEXT: ret i32 [[TMP4]]
51 a
= __builtin_assume_aligned(a
, 32);
55 // CHECK-LABEL: @test4(
57 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
58 // CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
59 // CHECK-NEXT: store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
60 // CHECK-NEXT: store i32 [[B:%.*]], ptr [[B_ADDR]], align 4
61 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
62 // CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[B_ADDR]], align 4
63 // CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP2]] to i64
64 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[TMP0]], i64 32, i64 [[CONV]]) ]
65 // CHECK-NEXT: store ptr [[TMP0]], ptr [[A_ADDR]], align 8
66 // CHECK-NEXT: [[TMP4:%.*]] = load ptr, ptr [[A_ADDR]], align 8
67 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP4]], i64 0
68 // CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
69 // CHECK-NEXT: ret i32 [[TMP5]]
71 int test4(int *a
, int b
) {
72 a
= __builtin_assume_aligned(a
, 32, b
);
76 int *m1(void) __attribute__((assume_aligned(64)));
78 // CHECK-LABEL: @test5(
80 // CHECK-NEXT: [[CALL:%.*]] = call align 64 ptr @m1()
81 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[CALL]], align 4
82 // CHECK-NEXT: ret i32 [[TMP0]]
88 int *m2(void) __attribute__((assume_aligned(64, 12)));
90 // CHECK-LABEL: @test6(
92 // CHECK-NEXT: [[CALL:%.*]] = call ptr @m2()
93 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[CALL]], i64 64, i64 12) ]
94 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[CALL]], align 4
95 // CHECK-NEXT: ret i32 [[TMP0]]
101 // CHECK-LABEL: @pr43638(
102 // CHECK-NEXT: entry:
103 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
104 // CHECK-NEXT: store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
105 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
106 // CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[TMP0]], i64 4294967296) ]
107 // CHECK-NEXT: store ptr [[TMP0]], ptr [[A_ADDR]], align 8
108 // CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr [[A_ADDR]], align 8
109 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 0
110 // CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
111 // CHECK-NEXT: ret i32 [[TMP4]]
113 int pr43638(int *a
) {
114 a
= __builtin_assume_aligned(a
, 4294967296);