llvm.org GIT mirror llvm / 069d6f3
Non-affine post-inc SCEV expansions have more code which must be emitted after the increment. Make sure the insert position reflects this. This fixes PR6453. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97537 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
3 changed file(s) with 51 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
10861086 // If the SCEV is computable at this level, insert it into the header
10871087 // after the PHIs (and after any other instructions that we've inserted
10881088 // there) so that it is guaranteed to dominate any user inside the loop.
1089 if (L && S->hasComputableLoopEvolution(L))
1089 if (L && S->hasComputableLoopEvolution(L) && L != PostIncLoop)
10901090 InsertPt = L->getHeader()->getFirstNonPHI();
10911091 while (isInsertedInstruction(InsertPt))
10921092 InsertPt = llvm::next(BasicBlock::iterator(InsertPt));
27922792 if (Instruction *I =
27932793 dyn_cast(cast(LF.UserInst)->getOperand(1)))
27942794 Inputs.push_back(I);
2795 if (LF.PostIncLoop && !L->contains(LF.UserInst))
2796 Inputs.push_back(L->getLoopLatch()->getTerminator());
2795 if (LF.PostIncLoop) {
2796 if (!L->contains(LF.UserInst))
2797 Inputs.push_back(L->getLoopLatch()->getTerminator());
2798 else
2799 Inputs.push_back(IVIncInsertPos);
2800 }
27972801
27982802 // Then, climb up the immediate dominator tree as far as we can go while
27992803 // still being dominated by the input positions.
0 ; RUN: opt < %s -loop-reduce
1 ; PR6453
2
3 target datalayout = "e-p:64:64:64"
4
5 define void @_ZNK15PolynomialSpaceILi3EE13compute_indexEjRA3_j() nounwind {
6 entry:
7 br label %bb6
8
9 bb6:
10 %t4 = phi i32 [ 0, %entry ], [ %t3, %bb5 ]
11 %t16 = sub i32 undef, %t4
12 %t25 = sub i32 undef, %t4
13 %t26 = add i32 undef, %t25
14 br label %bb4
15
16 bb4:
17 %t2 = phi i32 [ %t1, %bb3 ], [ 0, %bb6 ]
18 %t17 = mul i32 %t2, %t16
19 %t18 = zext i32 %t2 to i33
20 %t19 = add i32 %t2, -1
21 %t20 = zext i32 %t19 to i33
22 %t21 = mul i33 %t18, %t20
23 %t22 = lshr i33 %t21, 1
24 %t23 = trunc i33 %t22 to i32
25 %t24 = sub i32 %t17, %t23
26 %t27 = add i32 %t24, %t26
27 br i1 false, label %bb1, label %bb5
28
29 bb1:
30 %t = icmp ugt i32 %t27, undef
31 br i1 %t, label %bb2, label %bb3
32
33 bb3:
34 %t1 = add i32 %t2, 1
35 br label %bb4
36
37 bb5:
38 %t3 = add i32 %t4, 1
39 br label %bb6
40
41 bb2:
42 ret void
43 }