blob: a635be10d465f30787771fe738843c8ab5173d96 [file] [log] [blame]
Justin Lebar96e29152016-11-29 21:49:02 +00001; RUN: opt -o /dev/null -structurizecfg %s
2
3; The following function caused an infinite loop inside the structurizer's
4; rebuildSSA routine, where we were iterating over an instruction's uses while
5; modifying the use list, without taking care to do this safely.
6
7target triple = "amdgcn--"
8
9declare <4 x float> @llvm.SI.vs.load.input(<16 x i8>, i32, i32) #0
10declare <4 x float> @llvm.amdgcn.image.load.v4f32.v2i32.v8i32(<2 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
11declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float) #2
12
13define amdgpu_vs void @wrapper(i32 inreg, i32) {
14main_body:
15 %2 = add i32 %1, %0
16 %3 = call <4 x float> @llvm.SI.vs.load.input(<16 x i8> undef, i32 0, i32 %2)
17 %4 = extractelement <4 x float> %3, i32 1
18 %5 = fptosi float %4 to i32
19 %6 = insertelement <2 x i32> undef, i32 %5, i32 1
20 br label %loop11.i
21
22loop11.i: ; preds = %endif46.i, %main_body
23 %7 = phi i32 [ 0, %main_body ], [ %15, %endif46.i ]
24 %8 = icmp sgt i32 %7, 999
25 br i1 %8, label %main.exit, label %if16.i
26
27if16.i: ; preds = %loop11.i
28 %9 = call <4 x float> @llvm.amdgcn.image.load.v4f32.v2i32.v8i32(<2 x i32> %6, <8 x i32> undef, i32 15, i1 true, i1 false, i1 false, i1 false)
29 %10 = extractelement <4 x float> %9, i32 0
30 %11 = fcmp ult float 0.000000e+00, %10
31 br i1 %11, label %if28.i, label %endif46.i
32
33if28.i: ; preds = %if16.i
34 %12 = bitcast float %10 to i32
35 %13 = shl i32 %12, 16
36 %14 = bitcast i32 %13 to float
37 br label %main.exit
38
39endif46.i: ; preds = %if16.i
40 %15 = add i32 %7, 1
41 br label %loop11.i
42
43main.exit: ; preds = %if28.i, %loop11.i
44 %16 = phi float [ %14, %if28.i ], [ 0x36F0800000000000, %loop11.i ]
45 call void @llvm.SI.export(i32 15, i32 0, i32 0, i32 32, i32 0, float %16, float 0.000000e+00, float 0.000000e+00, float 0x36A0000000000000)
46 ret void
47}
48
49attributes #0 = { nounwind readnone }
50attributes #1 = { nounwind readonly }
51attributes #2 = { nounwind }