1; RUN: llc -march=hexagon -O3 < %s
2; REQUIRES: asserts
3
4; Test that the compiler doesn't assert when attempting to find a
5; loop instruction that has been deleted, so FindLoopInstr returns
6; the loop instruction from a different loop.
7
8@g0 = external global i32
9
10; Function Attrs: nounwind
11define void @f0() #0 {
12b0:
13  %v0 = alloca i64, align 8
14  %v1 = bitcast i64* %v0 to [2 x i32]*
15  %v2 = load i32, i32* @g0, align 4
16  br i1 undef, label %b1, label %b2
17
18b1:                                               ; preds = %b1, %b0
19  %v3 = phi i32 [ %v4, %b1 ], [ 64, %b0 ]
20  %v4 = add nsw i32 %v3, 1
21  %v5 = icmp slt i32 %v4, %v2
22  br i1 %v5, label %b1, label %b2
23
24b2:                                               ; preds = %b6, %b3, %b1, %b0
25  br label %b4
26
27b3:                                               ; preds = %b4
28  br i1 undef, label %b4, label %b2
29
30b4:                                               ; preds = %b3, %b2
31  %v6 = icmp slt i32 undef, 1
32  br i1 %v6, label %b3, label %b5
33
34b5:                                               ; preds = %b5, %b4
35  %v7 = phi i32 [ %v18, %b5 ], [ 1, %b4 ]
36  %v8 = phi i32 [ %v19, %b5 ], [ 0, %b4 ]
37  %v9 = add nsw i32 %v8, 0
38  %v10 = lshr i32 %v9, 5
39  %v11 = getelementptr inbounds [2 x i32], [2 x i32]* %v1, i32 0, i32 %v10
40  %v12 = load i32, i32* %v11, align 4
41  %v13 = and i32 %v9, 31
42  %v14 = shl i32 1, %v13
43  %v15 = and i32 %v12, %v14
44  %v16 = icmp ne i32 %v15, 0
45  %v17 = zext i1 %v16 to i32
46  %v18 = and i32 %v17, %v7
47  %v19 = add nsw i32 %v8, 1
48  %v20 = icmp eq i32 %v19, 1
49  br i1 %v20, label %b6, label %b5
50
51b6:                                               ; preds = %b5
52  %v21 = icmp eq i32 %v18, 0
53  br i1 %v21, label %b2, label %b7
54
55b7:                                               ; preds = %b6
56  tail call void @f1() #1
57  unreachable
58}
59
60; Function Attrs: nounwind
61declare void @f1() #1
62
63attributes #0 = { nounwind "target-cpu"="hexagonv55" }
64attributes #1 = { nounwind }
65