]> granicus.if.org Git - llvm/commitdiff
[SCEV] Take correct loop in AddRec simplification. PR40420
authorMax Kazantsev <max.kazantsev@azul.com>
Tue, 29 Jan 2019 05:37:59 +0000 (05:37 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Tue, 29 Jan 2019 05:37:59 +0000 (05:37 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352451 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/pr40420.ll

index 2ca494e8d66985acd3f2d75806a186e1625bccd9..1796fd338c1f6b6acdbc5af928f5fc4c646607f9 100644 (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;
index 3dd6edede6f7fb1ef43cf5e4e222562557c63c17..0f57958c24c6da51833b2543a5b943ed616376e6 100644 (file)
@@ -1,5 +1,4 @@
 ; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s
-; XFAIL: *
 ; REQUIRES: asserts
 
 define void @test(i8 %tmp6) {