From: Johannes Doerfert Date: Sun, 21 Feb 2016 16:36:00 +0000 (+0000) Subject: [FIX] Compare SCEVs not values during SCEV expansion X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85b04dedf4f7855bc48c3a83edac08a65a408531;p=platform%2Fupstream%2Fllvm.git [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. llvm-svn: 261474 --- diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp index 63f91b8..f845be8 100644 --- a/polly/lib/Support/ScopHelper.cpp +++ b/polly/lib/Support/ScopHelper.cpp @@ -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(E->getValue()); if (!Inst || (Inst->getOpcode() != Instruction::SRem &&