[polly] r261474 - [FIX] Compare SCEVs not values during SCEV expansion

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 21 08:36:00 PST 2016


Author: jdoerfert
Date: Sun Feb 21 10:36:00 2016
New Revision: 261474

URL: http://llvm.org/viewvc/llvm-project?rev=261474&view=rev
Log:
[FIX] Compare SCEVs not values during SCEV expansion

  This fixes a compile time bug in SPEC2006 403.gcc, namely an endless
  recursion in the ScopExpander::visitUnknown function.


Modified:
    polly/trunk/lib/Support/ScopHelper.cpp

Modified: polly/trunk/lib/Support/ScopHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=261474&r1=261473&r2=261474&view=diff
==============================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp (original)
+++ polly/trunk/lib/Support/ScopHelper.cpp Sun Feb 21 10:36:00 2016
@@ -249,10 +249,15 @@ private:
   const SCEV *visitUnknown(const SCEVUnknown *E) {
 
     // If a value mapping was given try if the underlying value is remapped.
-    if (VMap)
-      if (Value *NewVal = VMap->lookup(E->getValue()))
-        if (NewVal != E->getValue())
-          return visit(SE.getSCEV(NewVal));
+    Value *NewVal = VMap ? VMap->lookup(E->getValue()) : nullptr;
+    if (NewVal) {
+      auto *NewE = SE.getSCEV(NewVal);
+
+      // While the mapped value might be different the SCEV representation might
+      // not be. To this end we will check before we go into recursion here.
+      if (E != NewE)
+        return visit(NewE);
+    }
 
     Instruction *Inst = dyn_cast<Instruction>(E->getValue());
     if (!Inst || (Inst->getOpcode() != Instruction::SRem &&




More information about the llvm-commits mailing list