1; RUN: llc -march=hexagon -mcpu=hexagonv5 -O3 < %s | FileCheck %s
2
3; Test that we do not generate a hardware loop due to a potential underflow.
4
5; CHECK-NOT: loop0
6
7%struct.3 = type { i8*, i8, i8, i32, i32, i16, i16, i16, i16, i16, i16, i16, %struct.2* }
8%struct.2 = type { i16, i16, i16, i16, %struct.1* }
9%struct.1 = type { %struct.1*, %struct.0*, i32, i32, i16, [2 x i16], [2 x i16], i16 }
10%struct.0 = type { %struct.0*, i32, i32, i32, i32, i32, i32, i16, i16, i16, i8, i8, i8, i8 }
11
12@pairArray = external global i32**
13@carray = external global %struct.3**
14
15define void @test() #0 {
16entry:
17  %0 = load i32**, i32*** @pairArray, align 4
18  %1 = load %struct.3**, %struct.3*** @carray, align 4
19  br i1 undef, label %for.end110, label %for.body
20
21for.body:
22  %row.0199 = phi i32 [ %inc109, %for.inc108 ], [ 1, %entry ]
23  %arrayidx = getelementptr inbounds i32*, i32** %0, i32 %row.0199
24  %2 = load i32*, i32** %arrayidx, align 4
25  br i1 undef, label %for.body48, label %for.inc108
26
27for.cond45:
28  %cmp46 = icmp sgt i32 %dec58, 0
29  br i1 %cmp46, label %for.body48, label %for.inc108
30
31for.body48:
32  %i.1190 = phi i32 [ %dec58, %for.cond45 ], [ 0, %for.body ]
33  %arrayidx50 = getelementptr inbounds i32, i32* %2, i32 %i.1190
34  %3 = load i32, i32* %arrayidx50, align 4
35  %cmp53 = icmp slt i32 %3, 0
36  %dec58 = add nsw i32 %i.1190, -1
37  br i1 %cmp53, label %for.end59, label %for.cond45
38
39for.end59:
40  %cmp60 = icmp slt i32 %i.1190, 0
41  br i1 %cmp60, label %if.then65, label %for.inc108
42
43if.then65:
44  br label %for.body80
45
46for.body80:
47  %j.1196.in = phi i32 [ %j.1196, %for.body80 ], [ %i.1190, %if.then65 ]
48  %j.1196 = add nsw i32 %j.1196.in, 1
49  %arrayidx81 = getelementptr inbounds i32, i32* %2, i32 %j.1196
50  %4 = load i32, i32* %arrayidx81, align 4
51  %arrayidx82 = getelementptr inbounds %struct.3*, %struct.3** %1, i32 %4
52  %5 = load %struct.3*, %struct.3** %arrayidx82, align 4
53  %cxcenter83 = getelementptr inbounds %struct.3, %struct.3* %5, i32 0, i32 3
54  store i32 0, i32* %cxcenter83, align 4
55  %6 = load i32, i32* %arrayidx81, align 4
56  %arrayidx87 = getelementptr inbounds i32, i32* %2, i32 %j.1196.in
57  store i32 %6, i32* %arrayidx87, align 4
58  %exitcond = icmp eq i32 %j.1196, 0
59  br i1 %exitcond, label %for.inc108, label %for.body80
60
61for.inc108:
62  %inc109 = add nsw i32 %row.0199, 1
63  br i1 undef, label %for.body, label %for.end110
64
65for.end110:
66  ret void
67}
68