1 ; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s
2 ; Check that we remove the compare and induction variable instructions
3 ; after generating hardware loops.
7 ; CHECK-NOT: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#-1)
11 define i32 @test1(i32* nocapture %b, i32 %n) nounwind readonly {
13 %cmp1 = icmp sgt i32 %n, 0
14 br i1 %cmp1, label %for.body.preheader, label %for.end
19 for.body: ; preds = %for.body.preheader, %for.body
20 %sum.03 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
21 %arrayidx.phi = phi i32* [ %arrayidx.inc, %for.body ], [ %b, %for.body.preheader ]
22 %i.02 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
23 %0 = load i32* %arrayidx.phi, align 4
24 %add = add nsw i32 %0, %sum.03
25 %inc = add nsw i32 %i.02, 1
26 %exitcond = icmp eq i32 %inc, %n
27 %arrayidx.inc = getelementptr i32* %arrayidx.phi, i32 1
28 br i1 %exitcond, label %for.end.loopexit, label %for.body
34 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.end.loopexit ]
38 ; This test checks that that initial loop count value is removed.
39 ; CHECK-NOT: ={{.}}#40
41 ; CHECK-NOT: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#-1)
45 define i32 @test2(i32* nocapture %b) nounwind readonly {
50 %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
51 %arrayidx.phi = phi i32* [ %b, %entry ], [ %arrayidx.inc, %for.body ]
52 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
53 %0 = load i32* %arrayidx.phi, align 4
54 %add = add nsw i32 %0, %sum.02
55 %inc = add nsw i32 %i.01, 1
56 %exitcond = icmp eq i32 %inc, 40
57 %arrayidx.inc = getelementptr i32* %arrayidx.phi, i32 1
58 br i1 %exitcond, label %for.end, label %for.body
64 ; This test checks that we don't remove the induction variable since it's used.
66 ; CHECK: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#1)
69 define i32 @test3(i32* nocapture %b) nounwind {
74 %arrayidx.phi = phi i32* [ %b, %entry ], [ %arrayidx.inc, %for.body ]
75 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
76 store i32 %i.01, i32* %arrayidx.phi, align 4
77 %inc = add nsw i32 %i.01, 1
78 %exitcond = icmp eq i32 %inc, 40
79 %arrayidx.inc = getelementptr i32* %arrayidx.phi, i32 1
80 br i1 %exitcond, label %for.end, label %for.body