llvm.org GIT mirror llvm / 513fae2
Suppress the IV reversal transformation in the case that the RHS of the comparison is defined inside the loop. This fixes a use-before-def problem, because the transformation puts a use of the RHS outside the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72149 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
2 changed file(s) with 26 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
24552455 SCEVHandle One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType());
24562456 if (!AR || !AR->isAffine() || AR->getStepRecurrence(*SE) != One)
24572457 return;
2458 // If the RHS of the comparison is defined inside the loop, the rewrite
2459 // cannot be done.
2460 if (Instruction *CR = dyn_cast(Cond->getOperand(1)))
2461 if (L->contains(CR->getParent()))
2462 return;
24582463
24592464 // Make sure the IV is only used for counting. Value may be preinc or
24602465 // postinc; 2 uses in either case.
0 ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis \
1 ; RUN: | grep {icmp eq i2 %lsr.iv.next, %xmp4344}
2
3 ; Don't reverse the iteration if the rhs of the compare is defined
4 ; inside the loop.
5
6 define void @Fill_Buffer() nounwind {
7 entry:
8 br label %bb8
9
10 bb8:
11 %indvar34 = phi i32 [ 0, %entry ], [ %indvar.next35, %bb8 ]
12 %indvar3451 = trunc i32 %indvar34 to i2
13 %xmp4344 = xor i2 0, -1
14 %xmp104 = icmp eq i2 %indvar3451, %xmp4344
15 %indvar.next35 = add i32 %indvar34, 1
16 br i1 %xmp104, label %bb10, label %bb8
17
18 bb10:
19 unreachable
20 }