[Hexagon] Add an early if-conversion pass
[oota-llvm.git] / test / CodeGen / Hexagon / early-if-spare.ll
1 ; RUN: llc -O2 -mcpu=hexagonv5 < %s | FileCheck %s
2 ; Check if the three stores in the loop were predicated.
3 ; CHECK: if{{.*}}memw
4 ; CHECK: if{{.*}}memw
5 ; CHECK: if{{.*}}memw
6
7 target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32"
8 target triple = "hexagon"
9
10 define void @fred(i32 %n, i32* %bp) nounwind {
11 entry:
12   %cmp16 = icmp eq i32 %n, 0
13   br i1 %cmp16, label %for.end, label %for.body.lr.ph
14
15 for.body.lr.ph:                                   ; preds = %entry
16   %cmp2 = icmp ugt i32 %n, 32
17   br label %for.body
18
19 for.body:                                         ; preds = %for.inc, %for.body.lr.ph
20   %i.017 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
21   %call = tail call i32 @foo(i32* %bp) nounwind
22   %call1 = tail call i32 @bar(i32* %bp) nounwind
23   br i1 %cmp2, label %if.then, label %if.else
24
25 if.then:                                          ; preds = %for.body
26   %arrayidx = getelementptr inbounds i32, i32* %bp, i32 %i.017
27   store i32 %call, i32* %arrayidx, align 4, !tbaa !0
28   %add = add i32 %i.017, 2
29   %arrayidx3 = getelementptr inbounds i32, i32* %bp, i32 %add
30   store i32 %call1, i32* %arrayidx3, align 4, !tbaa !0
31   br label %for.inc
32
33 if.else:                                          ; preds = %for.body
34   %or = or i32 %call1, %call
35   %arrayidx4 = getelementptr inbounds i32, i32* %bp, i32 %i.017
36   store i32 %or, i32* %arrayidx4, align 4, !tbaa !0
37   br label %for.inc
38
39 for.inc:                                          ; preds = %if.then, %if.else
40   %inc = add i32 %i.017, 1
41   %exitcond = icmp eq i32 %inc, %n
42   br i1 %exitcond, label %for.end.loopexit, label %for.body
43
44 for.end.loopexit:                                 ; preds = %for.inc
45   br label %for.end
46
47 for.end:                                          ; preds = %for.end.loopexit, %entry
48   ret void
49 }
50
51 declare i32 @foo(i32*) nounwind
52
53 declare i32 @bar(i32*) nounwind
54
55 !0 = !{!"int", !1}
56 !1 = !{!"omnipotent char", !2}
57 !2 = !{!"Simple C/C++ TBAA"}