[llvm] r352451 - [SCEV] Take correct loop in AddRec simplification. PR40420

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 28 21:37:59 PST 2019


Author: mkazantsev
Date: Mon Jan 28 21:37:59 2019
New Revision: 352451

URL: http://llvm.org/viewvc/llvm-project?rev=352451&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
    llvm/trunk/test/Analysis/ScalarEvolution/pr40420.ll

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=352451&r1=352450&r2=352451&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jan 28 21:37:59 2019
@@ -3089,7 +3089,7 @@ const SCEV *ScalarEvolution::getMulExpr(
         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;

Modified: llvm/trunk/test/Analysis/ScalarEvolution/pr40420.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/pr40420.ll?rev=352451&r1=352450&r2=352451&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/pr40420.ll (original)
+++ llvm/trunk/test/Analysis/ScalarEvolution/pr40420.ll Mon Jan 28 21:37:59 2019
@@ -1,5 +1,4 @@
 ; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s
-; XFAIL: *
 ; REQUIRES: asserts
 
 define void @test(i8 %tmp6) {




More information about the llvm-commits mailing list