[SCEV] Pick backedge values for phi nodes correctly
[oota-llvm.git] / test / Transforms / IndVarSimplify / loop_evaluate9.ll
1 ; RUN: opt < %s -indvars -S > %t
2 ; RUN: grep "[%]tmp7 = icmp eq i8 -28, -28" %t
3 ; RUN: grep "[%]tmp8 = icmp eq i8 63, 63" %t
4 ; PR4477
5 ; Indvars should compute the exit values in loop.
6 ;
7 ; XFAIL: *
8 ; Indvars does not currently replace loop invariant values unless all
9 ; loop exits have the same exit value. We could handle some cases,
10 ; such as this, by making getSCEVAtScope() sensitive to a particular
11 ; loop exit.  See PR11388.
12
13 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
14 target triple = "i386-pc-linux-gnu"
15         %struct.cc70a02__complex_integers__complex_type = type { i8, i8 }
16 @.str = internal constant [13 x i8] c"fc70a00.adb\00\00", align 1               ; <[13 x i8]*> [#uses=1]
17
18 define void @_ada_cc70a02() {
19 entry:
20         br label %bb1.i
21
22 bb1.i:          ; preds = %bb2.i, %entry
23         %indvar.i = phi i32 [ 0, %entry ], [ %indvar.next.i, %bb2.i ]           ; <i32> [#uses=2]
24         %result.0.i = phi i16 [ 0, %entry ], [ %ins36.i, %bb2.i ]               ; <i16> [#uses=2]
25         %tmp38.i = trunc i16 %result.0.i to i8          ; <i8> [#uses=2]
26         %tmp = add i8 %tmp38.i, 96              ; <i8> [#uses=1]
27         %tmp1 = icmp ugt i8 %tmp, -56           ; <i1> [#uses=1]
28         br i1 %tmp1, label %bb.i.i, label %bb1.i.i
29
30 bb.i.i:         ; preds = %bb1.i
31         tail call void @__gnat_rcheck_12(i8* getelementptr ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i32 24) noreturn
32         unreachable
33
34 bb1.i.i:                ; preds = %bb1.i
35         %tmp41.i = lshr i16 %result.0.i, 8              ; <i16> [#uses=1]
36         %tmp42.i = trunc i16 %tmp41.i to i8             ; <i8> [#uses=2]
37         %tmp2 = add i8 %tmp42.i, 109            ; <i8> [#uses=1]
38         %tmp3 = icmp ugt i8 %tmp2, -56          ; <i1> [#uses=1]
39         br i1 %tmp3, label %bb2.i.i, label %cc70a02__complex_integers__Oadd.153.exit.i
40
41 bb2.i.i:                ; preds = %bb1.i.i
42         tail call void @__gnat_rcheck_12(i8* getelementptr ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i32 24) noreturn
43         unreachable
44
45 cc70a02__complex_integers__Oadd.153.exit.i:             ; preds = %bb1.i.i
46         %tmp4 = add i8 %tmp38.i, -4             ; <i8> [#uses=2]
47         %tmp5 = add i8 %tmp42.i, 9              ; <i8> [#uses=2]
48         %tmp25.i = zext i8 %tmp4 to i16         ; <i16> [#uses=1]
49         %tmp33.i = zext i8 %tmp5 to i16         ; <i16> [#uses=1]
50         %tmp34.i = shl i16 %tmp33.i, 8          ; <i16> [#uses=1]
51         %ins36.i = or i16 %tmp34.i, %tmp25.i            ; <i16> [#uses=1]
52         %tmp6 = icmp eq i32 %indvar.i, 6                ; <i1> [#uses=1]
53         br i1 %tmp6, label %cc70a02__complex_multiplication.170.exit, label %bb2.i
54
55 bb2.i:          ; preds = %cc70a02__complex_integers__Oadd.153.exit.i
56         %indvar.next.i = add i32 %indvar.i, 1           ; <i32> [#uses=1]
57         br label %bb1.i
58
59 cc70a02__complex_multiplication.170.exit:               ; preds = %cc70a02__complex_integers__Oadd.153.exit.i
60         %tmp7 = icmp eq i8 %tmp4, -28           ; <i1> [#uses=1]
61         %tmp8 = icmp eq i8 %tmp5, 63            ; <i1> [#uses=1]
62         %or.cond = and i1 %tmp8, %tmp7          ; <i1> [#uses=1]
63         br i1 %or.cond, label %return, label %bb1
64
65 bb1:            ; preds = %cc70a02__complex_multiplication.170.exit
66         tail call void @exit(i32 1)
67         ret void
68
69 return:         ; preds = %cc70a02__complex_multiplication.170.exit
70         ret void
71 }
72
73 declare fastcc void @cc70a02__complex_integers__complex.164(%struct.cc70a02__complex_integers__complex_type* noalias nocapture sret, i8 signext, i8 signext) nounwind
74
75 declare fastcc void @cc70a02__complex_integers__Osubtract.149(%struct.cc70a02__complex_integers__complex_type* noalias sret, %struct.cc70a02__complex_integers__complex_type* byval align 4)
76
77 declare fastcc void @cc70a02__complex_integers__Oadd.153(%struct.cc70a02__complex_integers__complex_type* noalias sret, %struct.cc70a02__complex_integers__complex_type* byval align 4, %struct.cc70a02__complex_integers__complex_type* byval align 4)
78
79 declare fastcc void @cc70a02__complex_multiplication.170(%struct.cc70a02__complex_integers__complex_type* noalias sret, %struct.cc70a02__complex_integers__complex_type* byval align 4)
80
81 declare void @__gnat_rcheck_12(i8*, i32) noreturn
82
83 declare void @exit(i32)