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: llc -march=amdgcn -verify-machineinstrs -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck -check-prefix=GCN %s
5 ; OPT-LABEL: @annotate_unreachable_noloop(
6 ; OPT-NOT: call i1 @llvm.amdgcn.loop
8 ; GCN-LABEL: {{^}}annotate_unreachable_noloop:
12 define amdgpu_kernel void @annotate_unreachable_noloop(<4 x float> addrspace(1)* noalias nocapture readonly %arg) #0 {
14 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
18 %tmp2 = sext i32 %tmp to i64
19 %tmp3 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %arg, i64 %tmp2
20 %tmp4 = load <4 x float>, <4 x float> addrspace(1)* %tmp3, align 16
21 br i1 undef, label %bb5, label %bb3
24 %tmp6 = extractelement <4 x float> %tmp4, i32 2
25 %tmp7 = fcmp olt float %tmp6, 0.000000e+00
26 br i1 %tmp7, label %bb4, label %bb5 ; crash goes away if these are swapped
31 bb5: ; preds = %bb3, %bb1
36 ; OPT-LABEL: @annotate_ret_noloop(
37 ; OPT-NOT: call i1 @llvm.amdgcn.loop
39 ; GCN-LABEL: {{^}}annotate_ret_noloop:
42 ; GCN: s_and_saveexec_b64
45 define amdgpu_kernel void @annotate_ret_noloop(<4 x float> addrspace(1)* noalias nocapture readonly %arg) #0 {
47 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x()
51 %tmp2 = sext i32 %tmp to i64
52 %tmp3 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %arg, i64 %tmp2
53 %tmp4 = load <4 x float>, <4 x float> addrspace(1)* %tmp3, align 16
54 %tmp5 = extractelement <4 x float> %tmp4, i32 1
55 store volatile <4 x float> %tmp4, <4 x float> addrspace(1)* undef
56 %cmp = fcmp ogt float %tmp5, 1.0
57 br i1 %cmp, label %bb5, label %bb3
60 %tmp6 = extractelement <4 x float> %tmp4, i32 2
61 %tmp7 = fcmp olt float %tmp6, 0.000000e+00
62 br i1 %tmp7, label %bb4, label %bb5 ; crash goes away if these are swapped
67 bb5: ; preds = %bb3, %bb1
71 ; OPT-LABEL: @uniform_annotate_ret_noloop(
72 ; OPT-NOT: call i1 @llvm.amdgcn.loop
74 ; GCN-LABEL: {{^}}uniform_annotate_ret_noloop:
78 define amdgpu_kernel void @uniform_annotate_ret_noloop(<4 x float> addrspace(1)* noalias nocapture readonly %arg, i32 %tmp) #0 {
83 %tmp2 = sext i32 %tmp to i64
84 %tmp3 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %arg, i64 %tmp2
85 %tmp4 = load <4 x float>, <4 x float> addrspace(1)* %tmp3, align 16
86 br i1 undef, label %bb5, label %bb3
89 %tmp6 = extractelement <4 x float> %tmp4, i32 2
90 %tmp7 = fcmp olt float %tmp6, 0.000000e+00
91 br i1 %tmp7, label %bb4, label %bb5 ; crash goes away if these are swapped
96 bb5: ; preds = %bb3, %bb1
101 declare i32 @llvm.amdgcn.workitem.id.x() #1
103 attributes #0 = { nounwind }
104 attributes #1 = { nounwind readnone }