[SCEV] Take correct loop in AddRec simplification. PR40420

The code of AddRec simplification is using wrong loop when it creates a new
AddRecExpr. It should be using AddRecLoop which we have saved and against which
all gate checks are made, and not calling AddRec->getLoop() over and over
again because AddRec may change and become an AddRecurrency from outer loop
during the transform iterations.

Considering this change trivial, commiting for postcommit review.

llvm-svn: 352451
This commit is contained in:
Max Kazantsev 2019-01-29 05:37:59 +00:00
parent d4de606ddb
commit 468ad52213
2 changed files with 1 additions and 2 deletions

View File

@ -3089,7 +3089,7 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
AddRecOps.push_back(getAddExpr(SumOps, SCEV::FlagAnyWrap, Depth + 1));
}
if (!Overflow) {
const SCEV *NewAddRec = getAddRecExpr(AddRecOps, AddRec->getLoop(),
const SCEV *NewAddRec = getAddRecExpr(AddRecOps, AddRecLoop,
SCEV::FlagAnyWrap);
if (Ops.size() == 2) return NewAddRec;
Ops[Idx] = NewAddRec;

View File

@ -1,5 +1,4 @@
; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s
; XFAIL: *
; REQUIRES: asserts
define void @test(i8 %tmp6) {