Don't (unconditionally) use getSCEVAtScope to simplify the step

expression in IVUsers, because in the case of a use of a non-linear
addrec outside of a loop, this causes the addrec to be evaluated as
a linear addrec.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73774 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-06-19 17:33:15 +00:00
parent ae60c0f78e
commit 958e292c7a
2 changed files with 18 additions and 1 deletions

View File

@ -112,7 +112,6 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L, Loop *UseLoop,
SCEVHandle AddRecStart = AddRec->getStart();
AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop);
SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE);
AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop);
// FIXME: If Start contains an SCEVAddRecExpr from a different loop, other
// than an outer loop of the current loop, reject it. LSR has no concept of

View File

@ -0,0 +1,18 @@
; RUN: llvm-as < %s | opt -analyze -iv-users -disable-output | grep {Stride i64 {1,+,2}<loop>:}
; The value of %r is dependent on a polynomial iteration expression.
define i64 @foo(i64 %n) {
entry:
br label %loop
loop:
%indvar = phi i64 [ 0, %entry ], [ %indvar.next, %loop ]
%indvar.next = add i64 %indvar, 1
%c = icmp eq i64 %indvar.next, %n
br i1 %c, label %exit, label %loop
exit:
%r = mul i64 %indvar, %indvar
ret i64 %r
}