1 ; RUN: opt -passes='default<O1>,instnamer' -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O1 %s
2 ; RUN: opt -passes='default<O2>,instnamer' -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O2 %s
3 ; RUN: opt -passes='default<O3>,instnamer' -mtriple=amdgcn-- -S -o - %s | FileCheck -check-prefixes=GCN,O3 %s
4 target datalayout = "A5"
10 ; GCN-COUNT-27: = load
12 define protected amdgpu_kernel void @t0(ptr addrspace(1) %p.coerce) #0 {
14 %p = alloca ptr, align 8, addrspace(5)
15 %p.ascast = addrspacecast ptr addrspace(5) %p to ptr
16 %p.addr = alloca ptr, align 8, addrspace(5)
17 %p.addr.ascast = addrspacecast ptr addrspace(5) %p.addr to ptr
18 %t = alloca [27 x i32], align 16, addrspace(5)
19 %t.ascast = addrspacecast ptr addrspace(5) %t to ptr
20 %sum = alloca i32, align 4, addrspace(5)
21 %sum.ascast = addrspacecast ptr addrspace(5) %sum to ptr
22 %i = alloca i32, align 4, addrspace(5)
23 %i.ascast = addrspacecast ptr addrspace(5) %i to ptr
24 %cleanup.dest.slot = alloca i32, align 4, addrspace(5)
25 %0 = addrspacecast ptr addrspace(1) %p.coerce to ptr
26 store ptr %0, ptr %p.ascast, align 8
27 %p1 = load ptr, ptr %p.ascast, align 8
28 store ptr %p1, ptr %p.addr.ascast, align 8
29 call void @llvm.lifetime.start.p5(i64 48, ptr addrspace(5) %t)
30 %1 = load ptr, ptr %p.addr.ascast, align 8
31 call void @copy(ptr %t.ascast, ptr %1, i32 27)
32 call void @llvm.lifetime.start.p5(i64 4, ptr addrspace(5) %sum)
33 store i32 0, ptr %sum.ascast, align 4
34 call void @llvm.lifetime.start.p5(i64 4, ptr addrspace(5) %i)
35 store i32 0, ptr %i.ascast, align 4
38 for.cond: ; preds = %for.inc, %entry
39 %2 = load i32, ptr %i.ascast, align 4
40 %cmp = icmp slt i32 %2, 27
41 br i1 %cmp, label %for.body, label %for.cond.cleanup
43 for.cond.cleanup: ; preds = %for.cond
44 call void @llvm.lifetime.end.p5(i64 4, ptr addrspace(5) %i)
47 for.body: ; preds = %for.cond
48 %3 = load i32, ptr %i.ascast, align 4
49 %idxprom = sext i32 %3 to i64
50 %arrayidx = getelementptr inbounds [27 x i32], ptr %t.ascast, i64 0, i64 %idxprom
51 %4 = load i32, ptr %arrayidx, align 4
52 %5 = load i32, ptr %sum.ascast, align 4
53 %add = add nsw i32 %5, %4
54 store i32 %add, ptr %sum.ascast, align 4
57 for.inc: ; preds = %for.body
58 %6 = load i32, ptr %i.ascast, align 4
59 %inc = add nsw i32 %6, 1
60 store i32 %inc, ptr %i.ascast, align 4
63 for.end: ; preds = %for.cond.cleanup
64 %7 = load i32, ptr %sum.ascast, align 4
65 %8 = load ptr, ptr %p.addr.ascast, align 8
66 store i32 %7, ptr %8, align 4
67 call void @llvm.lifetime.end.p5(i64 4, ptr addrspace(5) %sum)
68 call void @llvm.lifetime.end.p5(i64 48, ptr addrspace(5) %t)
72 define internal void @copy(ptr %d, ptr %s, i32 %N) {
75 tail call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 %N8, i1 false)
79 declare void @llvm.lifetime.start.p5(i64 immarg, ptr addrspace(5) nocapture)
80 declare void @llvm.lifetime.end.p5(i64 immarg, ptr addrspace(5) nocapture)
81 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1)