1 ; RUN: opt < %s -loop-reduce -S
3 ; Test that SCEV insertpoint's don't get corrupted and cause an
4 ; invalid instruction to be inserted in a block other than its parent.
5 ; See http://reviews.llvm.org/D20703 for context.
8 %bf.load = load i32, ptr null, align 4
9 %bf.clear = lshr i32 %bf.load, 1
10 %div = and i32 %bf.clear, 134217727
11 %sub = add nsw i32 %div, -1
12 %0 = zext i32 %sub to i64
15 while.cond: ; preds = %cond.end, %entry
16 %indvars.iv = phi i64 [ %indvars.iv.next, %cond.end ], [ 0, %entry ]
17 %cmp = icmp eq i64 %indvars.iv, %0
18 br i1 %cmp, label %cleanup16, label %while.body
20 while.body: ; preds = %while.cond
21 %1 = trunc i64 %indvars.iv to i32
23 %add = add nuw i32 %mul, 2
24 %cmp3 = icmp ult i32 %add, 0
25 br i1 %cmp3, label %if.end, label %if.then
27 if.then: ; preds = %while.body
30 if.end: ; preds = %while.body
31 br i1 false, label %cond.end, label %cond.true
33 cond.true: ; preds = %if.end
36 cond.end: ; preds = %cond.true, %if.end
38 %cmp12 = icmp ugt i32 %add7, %sub
39 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
40 br i1 %cmp12, label %if.then13, label %while.cond
42 if.then13: ; preds = %cond.end
45 cleanup16: ; preds = %while.cond