1 ; RUN: opt -mtriple=amdgcn-- -S -structurizecfg -si-annotate-control-flow -simplifycfg-require-and-preserve-domtree=1 %s | FileCheck -check-prefix=OPT %s
2 ; RUN: opt -mtriple=amdgcn-- -S -passes=structurizecfg,si-annotate-control-flow -simplifycfg-require-and-preserve-domtree=1 %s | FileCheck -check-prefix=OPT %s
3 ; RUN: llc -mtriple=amdgcn -verify-machineinstrs -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck -check-prefix=GCN %s
6 ; OPT-LABEL: @annotate_unreachable_noloop(
7 ; OPT-NOT: call i1 @llvm.amdgcn.loop
9 ; GCN-LABEL: {{^}}annotate_unreachable_noloop:
13 define amdgpu_kernel void @annotate_unreachable_noloop(ptr addrspace(1) noalias nocapture readonly %arg) #0 {
15 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
19 %tmp2 = sext i32 %tmp to i64
20 %tmp3 = getelementptr inbounds <4 x float>, ptr addrspace(1) %arg, i64 %tmp2
21 %tmp4 = load <4 x float>, ptr addrspace(1) %tmp3, align 16
22 br i1 undef, label %bb5, label %bb3
25 %tmp6 = extractelement <4 x float> %tmp4, i32 2
26 %tmp7 = fcmp olt float %tmp6, 0.000000e+00
27 br i1 %tmp7, label %bb4, label %bb5 ; crash goes away if these are swapped
32 bb5: ; preds = %bb3, %bb1
37 ; OPT-LABEL: @annotate_ret_noloop(
38 ; OPT-NOT: call i1 @llvm.amdgcn.loop
40 ; GCN-LABEL: {{^}}annotate_ret_noloop:
43 ; GCN: s_and_saveexec_b64
46 define amdgpu_kernel void @annotate_ret_noloop(ptr addrspace(1) noalias nocapture readonly %arg) #0 {
48 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
52 %tmp2 = sext i32 %tmp to i64
53 %tmp3 = getelementptr inbounds <4 x float>, ptr addrspace(1) %arg, i64 %tmp2
54 %tmp4 = load <4 x float>, ptr addrspace(1) %tmp3, align 16
55 %tmp5 = extractelement <4 x float> %tmp4, i32 1
56 store volatile <4 x float> %tmp4, ptr addrspace(1) undef
57 %cmp = fcmp ogt float %tmp5, 1.0
58 br i1 %cmp, label %bb5, label %bb3
61 %tmp6 = extractelement <4 x float> %tmp4, i32 2
62 %tmp7 = fcmp olt float %tmp6, 0.000000e+00
63 br i1 %tmp7, label %bb4, label %bb5 ; crash goes away if these are swapped
68 bb5: ; preds = %bb3, %bb1
72 ; OPT-LABEL: @uniform_annotate_ret_noloop(
73 ; OPT-NOT: call i1 @llvm.amdgcn.loop
75 ; GCN-LABEL: {{^}}uniform_annotate_ret_noloop:
79 define amdgpu_kernel void @uniform_annotate_ret_noloop(ptr addrspace(1) noalias nocapture readonly %arg, i32 %tmp) #0 {
84 %tmp2 = sext i32 %tmp to i64
85 %tmp3 = getelementptr inbounds <4 x float>, ptr addrspace(1) %arg, i64 %tmp2
86 %tmp4 = load <4 x float>, ptr addrspace(1) %tmp3, align 16
87 br i1 undef, label %bb5, label %bb3
90 %tmp6 = extractelement <4 x float> %tmp4, i32 2
91 %tmp7 = fcmp olt float %tmp6, 0.000000e+00
92 br i1 %tmp7, label %bb4, label %bb5 ; crash goes away if these are swapped
97 bb5: ; preds = %bb3, %bb1
102 declare i32 @llvm.amdgcn.workitem.id.x() #1
104 attributes #0 = { nounwind }
105 attributes #1 = { nounwind readnone }