Author: dpatel
Date: Wed Feb 13 16:23:07 2008
New Revision: 47093

URL: http://llvm.org/viewvc/llvm-project?rev=47093&view=rev
Log:
A loop latch phi node may have uses inside loop, not just in loop header.

Added:
    llvm/trunk/test/Transforms/LoopIndexSplit/2008-02-13-LoopLatchPHI.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=47093&r1=47092&r2=47093&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Wed Feb 13 16:23:07 2008
@@ -151,7 +151,7 @@
     /// Update ExitBB PHINodes' to reflect this change.
     void updatePHINodes(BasicBlock *ExitBB, BasicBlock *Latch, 
                         BasicBlock *Header,
-                        PHINode *IV, Instruction *IVIncrement);
+                        PHINode *IV, Instruction *IVIncrement, Loop *LP);
 
     /// moveExitCondition - Move exit condition EC into split condition block 
CondBB.
     void moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
@@ -1597,7 +1597,7 @@
   new BranchInst(OrigDestBB, ExitingBB);
 
   // Update PHINodes
-  updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd);
+  updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd, LP);
 
   // Fix dominator info.
   // ExitBB is now dominated by CondBB
@@ -1637,7 +1637,8 @@
 /// Update ExitBB PHINodes' to reflect this change.
 void LoopIndexSplit::updatePHINodes(BasicBlock *ExitBB, BasicBlock *Latch, 
                                     BasicBlock *Header,
-                                    PHINode *IV, Instruction *IVIncrement) {
+                                    PHINode *IV, Instruction *IVIncrement,
+                                    Loop *LP) {
 
   for (BasicBlock::iterator BI = ExitBB->begin(), BE = ExitBB->end(); 
        BI != BE; ++BI) {
@@ -1653,7 +1654,7 @@
       for (Value::use_iterator UI = PHV->use_begin(), E = PHV->use_end(); 
            UI != E; ++UI) 
         if (PHINode *U = dyn_cast<PHINode>(*UI)) 
-          if (U->getParent() == Header) {
+          if (LP->contains(U->getParent())) {
             NewV = U;
             break;
           }

Added: llvm/trunk/test/Transforms/LoopIndexSplit/2008-02-13-LoopLatchPHI.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopIndexSplit/2008-02-13-LoopLatchPHI.ll?rev=47093&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/LoopIndexSplit/2008-02-13-LoopLatchPHI.ll (added)
+++ llvm/trunk/test/Transforms/LoopIndexSplit/2008-02-13-LoopLatchPHI.ll Wed 
Feb 13 16:23:07 2008
@@ -0,0 +1,74 @@
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output
+; PR 2011
+       %struct.CLAUSE_HELP = type { i32, i32, i32, i32, i32*, i32, 
%struct.LIST_NODE*, %struct.LIST_NODE*, i32, i32, %struct.LITERAL_HELP**, i32, 
i32, i32, i32 }
+       %struct.LIST_NODE = type { %struct.LIST_NODE*, i8* }
+       %struct.LITERAL_HELP = type { i32, i32, i32, %struct.CLAUSE_HELP*, 
%struct.term* }
+       %struct.anon = type { %struct.LIST_NODE* }
+       %struct.st = type { %struct.subst*, %struct.LIST_NODE*, 
%struct.LIST_NODE*, i16, i16 }
+       %struct.subst = type { %struct.subst*, i32, %struct.term* }
+       %struct.term = type { i32, %struct.anon, %struct.LIST_NODE*, i32, i32 }
+
+define fastcc %struct.LIST_NODE* @inf_HyperResolvents(%struct.CLAUSE_HELP* 
%Clause, %struct.subst* %Subst, %struct.LIST_NODE* %Restlits, i32 
%GlobalMaxVar, %struct.LIST_NODE* %FoundMap, i32 %StrictlyMaximal, { 
%struct.st*, [3001 x %struct.term*], [4000 x %struct.term*], i32 }* %Index, 
i32* %Flags, i32* %Precedence) nounwind  {
+entry:
+       br i1 false, label %bb960, label %bb885
+
+bb885:         ; preds = %entry
+       ret %struct.LIST_NODE* null
+
+bb960:         ; preds = %entry
+       br i1 false, label %bb1097, label %bb1005.preheader
+
+bb1005.preheader:              ; preds = %bb960
+       ret %struct.LIST_NODE* null
+
+bb1097:                ; preds = %bb960
+       br i1 false, label %bb1269.preheader, label %bb1141.preheader
+
+bb1141.preheader:              ; preds = %bb1097
+       ret %struct.LIST_NODE* null
+
+bb1269.preheader:              ; preds = %bb1097
+       br i1 false, label %bb1318, label %bb1281
+
+bb1281:                ; preds = %bb1269.preheader
+       ret %struct.LIST_NODE* null
+
+bb1318:                ; preds = %bb1269.preheader
+       br i1 false, label %bb1459, label %bb.nph52
+
+bb.nph52:              ; preds = %bb1318
+       ret %struct.LIST_NODE* null
+
+bb1459:                ; preds = %bb1318
+       br i1 false, label %bb1553, label %bb.nph62
+
+bb.nph62:              ; preds = %bb1459
+       ret %struct.LIST_NODE* null
+
+bb1553:                ; preds = %bb1669, %bb1459
+       %j295.0.reg2mem.0 = phi i32 [ %storemerge110, %bb1669 ], [ 0, %bb1459 ] 
        ; <i32> [#uses=2]
+       %Constraint403.2.reg2mem.0 = phi %struct.LIST_NODE* [ 
%Constraint403.1.reg2mem.0, %bb1669 ], [ null, %bb1459 ]          ; 
<%struct.LIST_NODE*> [#uses=1]
+       br i1 false, label %bb1588, label %bb1616
+
+bb1588:                ; preds = %bb1553
+       br label %bb1616
+
+bb1616:                ; preds = %bb1588, %bb1553
+       %tmp1629 = icmp sgt i32 %j295.0.reg2mem.0, 0            ; <i1> [#uses=1]
+       br i1 %tmp1629, label %bb1649, label %bb1632
+
+bb1632:                ; preds = %bb1616
+       br label %bb1669
+
+bb1649:                ; preds = %bb1616
+       br label %bb1669
+
+bb1669:                ; preds = %bb1649, %bb1632
+       %Constraint403.1.reg2mem.0 = phi %struct.LIST_NODE* [ null, %bb1632 ], 
[ %Constraint403.2.reg2mem.0, %bb1649 ]          ; <%struct.LIST_NODE*> 
[#uses=1]
+       %storemerge110 = add i32 %j295.0.reg2mem.0, 1           ; <i32> 
[#uses=2]
+       %tmp1672 = icmp sgt i32 %storemerge110, 0               ; <i1> [#uses=1]
+       br i1 %tmp1672, label %bb1678, label %bb1553
+
+bb1678:                ; preds = %bb1669
+       ret %struct.LIST_NODE* null
+}


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to