[llvm-branch-commits] [llvm-branch] r232416 - Merge r232189 from trunk to 3.6

Sanjoy Das sanjoy at playingwithpointers.com
Mon Mar 16 14:15:49 PDT 2015


Author: sanjoy
Date: Mon Mar 16 16:15:49 2015
New Revision: 232416

URL: http://llvm.org/viewvc/llvm-project?rev=232416&view=rev
Log:
Merge r232189 from trunk to 3.6

Original commit message:

Summary:
ScalarEvolutionExpander assumes that the header block of a loop is a
legal place to have a use for a phi node.  This is true only for phis
that are either in the header or dominate the header block, but it is
not true for phi nodes that are strictly internal to the loop body.

This change teaches ScalarEvolutionExpander to place uses of PHI nodes
in the basic block the PHI nodes belong to.  This is always legal, and
`hoistIVInc` ensures that the said position dominates `IsomorphicInc`.

Reviewers: atrick

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8311


Added:
    llvm/branches/release_36/test/Analysis/ScalarEvolution/pr22856.ll
      - copied unchanged from r232189, llvm/trunk/test/Analysis/ScalarEvolution/pr22856.ll
Modified:
    llvm/branches/release_36/   (props changed)
    llvm/branches/release_36/lib/Analysis/ScalarEvolutionExpander.cpp

Propchange: llvm/branches/release_36/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 16 16:15:49 2015
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,226023,226029,226044,226046,226048,226058,226075,226170-226171,226182,226473,226588,226616,226664,226708,226711,226755,226791,226808-226809,227005,227085,227087,227089,227250,227260-227261,227290,227294,227299,227319,227339,227491,227584,227603,227628,227670,227809,227815,227903,227934,227972,227983,228049,228129,228168,228331,228411,228444,228490,228500,228507,228518,228525,228565,228656,228760-228761,228793,228842,228899,228957,228969,228979,229029,229343,229351-229352,229421,229495,229529,229731,229911,230058,231563,232085
+/llvm/trunk:155241,226023,226029,226044,226046,226048,226058,226075,226170-226171,226182,226473,226588,226616,226664,226708,226711,226755,226791,226808-226809,227005,227085,227087,227089,227250,227260-227261,227290,227294,227299,227319,227339,227491,227584,227603,227628,227670,227809,227815,227903,227934,227972,227983,228049,228129,228168,228331,228411,228444,228490,228500,228507,228518,228525,228565,228656,228760-228761,228793,228842,228899,228957,228969,228979,229029,229343,229351-229352,229421,229495,229529,229731,229911,230058,231563,232085,232189

Modified: llvm/branches/release_36/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/Analysis/ScalarEvolutionExpander.cpp?rev=232416&r1=232415&r2=232416&view=diff
==============================================================================
--- llvm/branches/release_36/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/branches/release_36/lib/Analysis/ScalarEvolutionExpander.cpp Mon Mar 16 16:15:49 2015
@@ -1776,9 +1776,12 @@ unsigned SCEVExpander::replaceCongruentI
                         << *IsomorphicInc << '\n');
         Value *NewInc = OrigInc;
         if (OrigInc->getType() != IsomorphicInc->getType()) {
-          Instruction *IP = isa<PHINode>(OrigInc)
-            ? (Instruction*)L->getHeader()->getFirstInsertionPt()
-            : OrigInc->getNextNode();
+          Instruction *IP = nullptr;
+          if (PHINode *PN = dyn_cast<PHINode>(OrigInc))
+            IP = PN->getParent()->getFirstInsertionPt();
+          else
+            IP = OrigInc->getNextNode();
+
           IRBuilder<> Builder(IP);
           Builder.SetCurrentDebugLocation(IsomorphicInc->getDebugLoc());
           NewInc = Builder.





More information about the llvm-branch-commits mailing list