mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-08 18:31:23 +00:00
My last commit was not correct for nested loops. Fix it, and add a testcase for it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40498 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0d16988690
commit
9f435740b1
@ -731,6 +731,7 @@ Value *GVN::performPHIConstruction(BasicBlock *BB, LoadInst* orig,
|
|||||||
} else {
|
} else {
|
||||||
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle", BB->begin());
|
PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle", BB->begin());
|
||||||
PN->reserveOperandSpace(numPreds);
|
PN->reserveOperandSpace(numPreds);
|
||||||
|
Phis[BB] = PN;
|
||||||
|
|
||||||
visited.insert(BB);
|
visited.insert(BB);
|
||||||
// Fill in the incoming values for the block.
|
// Fill in the incoming values for the block.
|
||||||
@ -738,7 +739,7 @@ Value *GVN::performPHIConstruction(BasicBlock *BB, LoadInst* orig,
|
|||||||
if (!visited.count(*PI))
|
if (!visited.count(*PI))
|
||||||
PN->addIncoming(performPHIConstruction(*PI, orig, Phis, visited), *PI);
|
PN->addIncoming(performPHIConstruction(*PI, orig, Phis, visited), *PI);
|
||||||
else
|
else
|
||||||
PN->addIncoming(PN, *PI);
|
PN->addIncoming(Phis[*PI], *PI);
|
||||||
visited.erase(BB);
|
visited.erase(BB);
|
||||||
|
|
||||||
bool all_same = PN->getNumIncomingValues() != 1;
|
bool all_same = PN->getNumIncomingValues() != 1;
|
||||||
@ -748,6 +749,7 @@ Value *GVN::performPHIConstruction(BasicBlock *BB, LoadInst* orig,
|
|||||||
|
|
||||||
if (all_same) {
|
if (all_same) {
|
||||||
PN->eraseFromParent();
|
PN->eraseFromParent();
|
||||||
|
Phis[BB] = first;
|
||||||
return first;
|
return first;
|
||||||
} else {
|
} else {
|
||||||
return PN;
|
return PN;
|
||||||
|
38
test/Transforms/GVN/2007-07-25-NestedLoop.ll
Normal file
38
test/Transforms/GVN/2007-07-25-NestedLoop.ll
Normal file
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user