[llvm-commits] [llvm] r40498 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/2007-07-25-NestedLoop.ll
Owen Anderson
resistor at mac.com
Wed Jul 25 15:19:41 PDT 2007
Author: resistor
Date: Wed Jul 25 17:19:40 2007
New Revision: 40498
URL: http://llvm.org/viewvc/llvm-project?rev=40498&view=rev
Log:
My last commit was not correct for nested loops. Fix it, and add a testcase for it.
Added:
llvm/trunk/test/Transforms/GVN/2007-07-25-NestedLoop.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40498&r1=40497&r2=40498&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Jul 25 17:19:40 2007
@@ -731,6 +731,7 @@
} else {
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle", BB->begin());
PN->reserveOperandSpace(numPreds);
+ Phis[BB] = PN;
visited.insert(BB);
// Fill in the incoming values for the block.
@@ -738,7 +739,7 @@
if (!visited.count(*PI))
PN->addIncoming(performPHIConstruction(*PI, orig, Phis, visited), *PI);
else
- PN->addIncoming(PN, *PI);
+ PN->addIncoming(Phis[*PI], *PI);
visited.erase(BB);
bool all_same = PN->getNumIncomingValues() != 1;
@@ -748,6 +749,7 @@
if (all_same) {
PN->eraseFromParent();
+ Phis[BB] = first;
return first;
} else {
return PN;
Added: llvm/trunk/test/Transforms/GVN/2007-07-25-NestedLoop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2007-07-25-NestedLoop.ll?rev=40498&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GVN/2007-07-25-NestedLoop.ll (added)
+++ llvm/trunk/test/Transforms/GVN/2007-07-25-NestedLoop.ll Wed Jul 25 17:19:40 2007
@@ -0,0 +1,38 @@
+; RUN: llvm-as < %s | opt -gvn | llvm-dis
+
+ %struct.TypHeader = type { i32, %struct.TypHeader**, [3 x i8], i8 }
+
+define %struct.TypHeader* @LtRec(%struct.TypHeader* %hdL, %struct.TypHeader* %hdR) {
+entry:
+ br i1 false, label %bb556.preheader, label %bb534.preheader
+
+bb534.preheader: ; preds = %entry
+ ret %struct.TypHeader* null
+
+bb556.preheader: ; preds = %entry
+ %tmp56119 = getelementptr %struct.TypHeader* %hdR, i32 0, i32 0 ; <i32*> [#uses=1]
+ %tmp56220 = load i32* %tmp56119 ; <i32> [#uses=0]
+ br i1 false, label %bb.nph23, label %bb675.preheader
+
+bb.nph23: ; preds = %bb556.preheader
+ ret %struct.TypHeader* null
+
+bb656: ; preds = %bb675.outer, %bb656
+ %tmp678 = load i32* %tmp677 ; <i32> [#uses=0]
+ br i1 false, label %bb684, label %bb656
+
+bb684: ; preds = %bb675.outer, %bb656
+ br i1 false, label %bb924.preheader, label %bb675.outer
+
+bb675.outer: ; preds = %bb675.preheader, %bb684
+ %tmp67812 = load i32* %tmp67711 ; <i32> [#uses=0]
+ br i1 false, label %bb684, label %bb656
+
+bb675.preheader: ; preds = %bb556.preheader
+ %tmp67711 = getelementptr %struct.TypHeader* %hdR, i32 0, i32 0 ; <i32*> [#uses=1]
+ %tmp677 = getelementptr %struct.TypHeader* %hdR, i32 0, i32 0 ; <i32*> [#uses=1]
+ br label %bb675.outer
+
+bb924.preheader: ; preds = %bb684
+ ret %struct.TypHeader* null
+}
More information about the llvm-commits
mailing list