blob: e51a3410e35ac403006036b50f5ab39531c557a9 [file] [log] [blame]
Dan Gohman18800922009-09-11 18:01:28 +00001; RUN: opt < %s -indvars -S \
Chandler Carruthff123d52012-07-02 19:09:46 +00002; RUN: | grep "%b.1 = phi i32 [ 2, %bb ], [ 1, %bb2 ]"
Andrew Trick90c7a102011-11-16 00:52:40 +00003;
Dan Gohman03d5d0f2009-07-14 01:09:02 +00004; This loop has multiple exits, and the value of %b1 depends on which
5; exit is taken. Indvars should correctly compute the exit values.
Andrew Trick90c7a102011-11-16 00:52:40 +00006;
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.
Dan Gohman03d5d0f2009-07-14 01:09:02 +000012
13target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
Duncan Sands68c30902010-08-30 10:48:29 +000014target triple = "x86_64-pc-linux-gnu"
Dan Gohman03d5d0f2009-07-14 01:09:02 +000015 %struct..0anon = type <{ i8, [3 x i8] }>
16
17define i32 @main() nounwind {
18entry:
19 br label %bb2
20
21bb2: ; preds = %bb, %entry
22 %sdata.0 = phi i32 [ 1, %entry ], [ %ins10, %bb ] ; <i32> [#uses=2]
23 %b.0 = phi i32 [ 0, %entry ], [ %t0, %bb ] ; <i32> [#uses=2]
24 %tmp6 = trunc i32 %sdata.0 to i8 ; <i8> [#uses=2]
25 %t2 = and i8 %tmp6, 1 ; <i8> [#uses=1]
26 %t3 = icmp eq i8 %t2, 0 ; <i1> [#uses=1]
27 %t4 = xor i8 %tmp6, 1 ; <i8> [#uses=1]
28 %tmp8 = zext i8 %t4 to i32 ; <i32> [#uses=1]
29 %mask9 = and i32 %sdata.0, -256 ; <i32> [#uses=1]
30 %ins10 = or i32 %tmp8, %mask9 ; <i32> [#uses=1]
31 br i1 %t3, label %bb3, label %bb
32
33bb: ; preds = %bb2
34 %t0 = add i32 %b.0, 1 ; <i32> [#uses=3]
35 %t1 = icmp sgt i32 %t0, 100 ; <i1> [#uses=1]
36 br i1 %t1, label %bb3, label %bb2
37
38bb3: ; preds = %bb, %bb2
39 %b.1 = phi i32 [ %t0, %bb ], [ %b.0, %bb2 ] ; <i32> [#uses=1]
40 %t5 = icmp eq i32 %b.1, 1 ; <i1> [#uses=1]
41 br i1 %t5, label %bb5, label %bb4
42
43bb4: ; preds = %bb3
44 tail call void @abort() noreturn nounwind
45 unreachable
46
47bb5: ; preds = %bb3
48 ret i32 0
49}
50
51declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind
52
53declare void @abort() noreturn nounwind