1; RUN: llc -march=hexagon -disable-machine-licm -hwloop-spec-preheader=1 < %s | FileCheck %s
2; CHECK: loop0
3
4target triple = "hexagon"
5
6define i32 @foo(i32 %x, i32 %n, i32* nocapture %A, i32* nocapture %B) #0 {
7entry:
8  %cmp = icmp sgt i32 %x, 0
9  br i1 %cmp, label %for.cond.preheader, label %return
10
11for.cond.preheader:                               ; preds = %entry
12  %cmp16 = icmp sgt i32 %n, 0
13  br i1 %cmp16, label %for.body.preheader, label %return
14
15for.body.preheader:                               ; preds = %for.cond.preheader
16  br label %for.body
17
18for.body:                                         ; preds = %for.body.preheader, %for.body
19  %arrayidx.phi = phi i32* [ %arrayidx.inc, %for.body ], [ %B, %for.body.preheader ]
20  %arrayidx2.phi = phi i32* [ %arrayidx2.inc, %for.body ], [ %A, %for.body.preheader ]
21  %i.07 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
22  %0 = load i32, i32* %arrayidx.phi, align 4, !tbaa !0
23  %1 = load i32, i32* %arrayidx2.phi, align 4, !tbaa !0
24  %add = add nsw i32 %1, %0
25  store i32 %add, i32* %arrayidx2.phi, align 4, !tbaa !0
26  %inc = add nsw i32 %i.07, 1
27  %exitcond = icmp eq i32 %inc, %n
28  %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
29  %arrayidx2.inc = getelementptr i32, i32* %arrayidx2.phi, i32 1
30  br i1 %exitcond, label %return.loopexit, label %for.body
31
32return.loopexit:                                  ; preds = %for.body
33  br label %return
34
35return:                                           ; preds = %return.loopexit, %for.cond.preheader, %entry
36  %retval.0 = phi i32 [ 2, %entry ], [ 0, %for.cond.preheader ], [ 0, %return.loopexit ]
37  ret i32 %retval.0
38}
39
40!0 = !{!"int", !1}
41!1 = !{!"omnipotent char", !2}
42!2 = !{!"Simple C/C++ TBAA"}
43
44attributes #0 = { nounwind "target-cpu"="hexagonv60" "target-features"="-hvx" }
45