Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenOpenCL / amdgcn-automatic-variable.cl
blobf26495bc44aa3a731e1b918c5b34ba1fe1347e9a
1 // RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
2 // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
4 // CL12-LABEL: define{{.*}} void @func1(ptr addrspace(5) noundef %x)
5 // CL20-LABEL: define{{.*}} void @func1(ptr noundef %x)
6 void func1(int *x) {
7 // CL12: %[[x_addr:.*]] = alloca ptr addrspace(5){{.*}}addrspace(5)
8 // CL12: store ptr addrspace(5) %x, ptr addrspace(5) %[[x_addr]]
9 // CL12: %[[r0:.*]] = load ptr addrspace(5), ptr addrspace(5) %[[x_addr]]
10 // CL12: store i32 1, ptr addrspace(5) %[[r0]]
11 // CL20: %[[x_addr:.*]] = alloca ptr{{.*}}addrspace(5)
12 // CL20: store ptr %x, ptr addrspace(5) %[[x_addr]]
13 // CL20: %[[r0:.*]] = load ptr, ptr addrspace(5) %[[x_addr]]
14 // CL20: store i32 1, ptr %[[r0]]
15 *x = 1;
18 // CHECK-LABEL: define{{.*}} void @func2()
19 void func2(void) {
20 // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
21 // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
22 // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
23 // CL12: %lp1 = alloca ptr addrspace(5), align 4, addrspace(5)
24 // CL12: %lp2 = alloca ptr addrspace(5), align 4, addrspace(5)
25 // CL20: %lp1 = alloca ptr, align 8, addrspace(5)
26 // CL20: %lp2 = alloca ptr, align 8, addrspace(5)
27 // CHECK: %lvc = alloca i32, align 4, addrspace(5)
29 // CHECK: store i32 1, ptr addrspace(5) %lv1
30 int lv1;
31 lv1 = 1;
32 // CHECK: store i32 2, ptr addrspace(5) %lv2
33 int lv2 = 2;
35 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) %la, i64 0, i64 0
36 // CHECK: store i32 3, ptr addrspace(5) %[[arrayidx]], align 4
37 int la[100];
38 la[0] = 3;
40 // CL12: store ptr addrspace(5) %lv1, ptr addrspace(5) %lp1, align 4
41 // CL20: %[[r0:.*]] = addrspacecast ptr addrspace(5) %lv1 to ptr
42 // CL20: store ptr %[[r0]], ptr addrspace(5) %lp1, align 8
43 int *lp1 = &lv1;
45 // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], ptr addrspace(5) %la, i64 0, i64 0
46 // CL12: store ptr addrspace(5) %[[arraydecay]], ptr addrspace(5) %lp2, align 4
47 // CL20: %[[r1:.*]] = addrspacecast ptr addrspace(5) %[[arraydecay]] to ptr
48 // CL20: store ptr %[[r1]], ptr addrspace(5) %lp2, align 8
49 int *lp2 = la;
51 // CL12: call void @func1(ptr addrspace(5) noundef %lv1)
52 // CL20: %[[r2:.*]] = addrspacecast ptr addrspace(5) %lv1 to ptr
53 // CL20: call void @func1(ptr noundef %[[r2]])
54 func1(&lv1);
56 // CHECK: store i32 4, ptr addrspace(5) %lvc
57 // CHECK: store i32 4, ptr addrspace(5) %lv1
58 const int lvc = 4;
59 lv1 = lvc;
62 // CHECK-LABEL: define{{.*}} void @func3()
63 // CHECK: %a = alloca [16 x [1 x float]], align 4, addrspace(5)
64 // CHECK: call void @llvm.memset.p5.i64(ptr addrspace(5) align 4 %a, i8 0, i64 64, i1 false)
65 void func3(void) {
66 float a[16][1] = {{0.}};