1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; REQUIRES: amdgpu-registered-target
4 ; RUN: opt -globals-aa -loop-simplify -loop-load-elim -S %s | FileCheck %s
6 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
7 target triple = "amdgcn-amd-amdhsa"
9 %struct.foo = type { %struct.pluto, i8, i8*, i32 }
10 %struct.pluto = type { i32, i32, i32, %struct.wombat*, i32, i32, i32 }
11 %struct.wombat = type { %struct.barney }
12 %struct.barney = type { <2 x float> }
14 @global = external protected local_unnamed_addr addrspace(4) externally_initialized global %struct.foo, align 8
15 @global.1 = internal unnamed_addr addrspace(3) constant [4000 x float] undef, align 16
17 ; Function Attrs: nounwind
18 define protected amdgpu_kernel void @widget(i32 %arg, i32 %arg1) #0 {
19 ; CHECK-LABEL: @widget(
21 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds [4000 x float], [4000 x float] addrspace(3)* @global.1, i32 0, i32 [[ARG:%.*]]
22 ; CHECK-NEXT: [[TMP2:%.*]] = load %struct.wombat*, %struct.wombat* addrspace(4)* getelementptr inbounds (%struct.foo, [[STRUCT_FOO:%.*]] addrspace(4)* @global, i64 0, i32 0, i32 3), align 8
23 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[STRUCT_WOMBAT:%.*]], %struct.wombat* [[TMP2]], i64 undef, i32 0
24 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast %struct.barney* [[TMP3]] to i64*
25 ; CHECK-NEXT: br label [[BB5:%.*]]
26 ; CHECK: bb5.loopexit:
27 ; CHECK-NEXT: br label [[BB5]]
29 ; CHECK-NEXT: br label [[BB6:%.*]]
31 ; CHECK-NEXT: [[TMP7:%.*]] = phi i32 [ undef, [[BB5]] ], [ [[TMP19:%.*]], [[BB6]] ]
32 ; CHECK-NEXT: [[TMP8:%.*]] = mul nsw i32 [[TMP7]], undef
33 ; CHECK-NEXT: [[TMP9:%.*]] = add i32 [[TMP8]], undef
34 ; CHECK-NEXT: [[TMP10:%.*]] = sext i32 [[TMP9]] to i64
35 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds [[STRUCT_WOMBAT]], %struct.wombat* [[TMP2]], i64 [[TMP10]]
36 ; CHECK-NEXT: [[TMP12:%.*]] = bitcast %struct.wombat* [[TMP11]] to i64*
37 ; CHECK-NEXT: [[TMP13:%.*]] = load i64, i64* [[TMP12]], align 8
38 ; CHECK-NEXT: [[TMP14:%.*]] = srem i32 1, [[ARG1:%.*]]
39 ; CHECK-NEXT: [[TMP15:%.*]] = add nuw nsw i32 [[TMP14]], 1
40 ; CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds [4000 x float], [4000 x float] addrspace(3)* @global.1, i32 0, i32 [[TMP15]]
41 ; CHECK-NEXT: [[TMP17:%.*]] = load float, float addrspace(3)* [[TMP16]], align 4
42 ; CHECK-NEXT: [[TMP18:%.*]] = load float, float addrspace(3)* [[TMP]], align 4
43 ; CHECK-NEXT: store i64 [[TMP13]], i64* [[TMP4]], align 8
44 ; CHECK-NEXT: [[TMP19]] = add nsw i32 [[TMP7]], 1
45 ; CHECK-NEXT: [[TMP20:%.*]] = icmp slt i32 [[TMP7]], 3
46 ; CHECK-NEXT: br i1 [[TMP20]], label [[BB6]], label [[BB5_LOOPEXIT:%.*]]
49 %tmp = getelementptr inbounds [4000 x float], [4000 x float] addrspace(3)* @global.1, i32 0, i32 %arg
50 %tmp2 = load %struct.wombat*, %struct.wombat* addrspace(4)* getelementptr inbounds (%struct.foo, %struct.foo addrspace(4)* @global, i64 0, i32 0, i32 3), align 8
51 %tmp3 = getelementptr inbounds %struct.wombat, %struct.wombat* %tmp2, i64 undef, i32 0
52 %tmp4 = bitcast %struct.barney* %tmp3 to i64*
55 bb5: ; preds = %bb6, %bb
58 bb6: ; preds = %bb6, %bb5
59 %tmp7 = phi i32 [ undef, %bb5 ], [ %tmp19, %bb6 ]
60 %tmp8 = mul nsw i32 %tmp7, undef
61 %tmp9 = add i32 %tmp8, undef
62 %tmp10 = sext i32 %tmp9 to i64
63 %tmp11 = getelementptr inbounds %struct.wombat, %struct.wombat* %tmp2, i64 %tmp10
64 %tmp12 = bitcast %struct.wombat* %tmp11 to i64*
65 %tmp13 = load i64, i64* %tmp12, align 8
66 %tmp14 = srem i32 1, %arg1
67 %tmp15 = add nuw nsw i32 %tmp14, 1
68 %tmp16 = getelementptr inbounds [4000 x float], [4000 x float] addrspace(3)* @global.1, i32 0, i32 %tmp15
69 %tmp17 = load float, float addrspace(3)* %tmp16, align 4
70 %tmp18 = load float, float addrspace(3)* %tmp, align 4
71 store i64 %tmp13, i64* %tmp4, align 8
72 %tmp19 = add nsw i32 %tmp7, 1
73 %tmp20 = icmp slt i32 %tmp7, 3
74 br i1 %tmp20, label %bb6, label %bb5
77 attributes #0 = { nounwind }