[llvm-commits] [llvm] r68211 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/condprop.ll
Dan Gohman
gohman at apple.com
Wed Apr 1 09:37:48 PDT 2009
Author: djg
Date: Wed Apr 1 11:37:47 2009
New Revision: 68211
URL: http://llvm.org/viewvc/llvm-project?rev=68211&view=rev
Log:
Revert r68172. It caused regressions in
Applications/Burg/burg
Applications/ClamAV/clamscan
and many other tests.
Removed:
llvm/trunk/test/Transforms/GVN/condprop.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=68211&r1=68210&r2=68211&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Apr 1 11:37:47 2009
@@ -121,7 +121,6 @@
AliasAnalysis* AA;
MemoryDependenceAnalysis* MD;
DominatorTree* DT;
- uint32_t true_vn, false_vn;
uint32_t nextValueNumber;
@@ -139,14 +138,7 @@
Expression create_expression(CallInst* C);
Expression create_expression(Constant* C);
public:
- ValueTable() : nextValueNumber(1) {
- true_vn = lookup_or_add(ConstantInt::getTrue());
- false_vn = lookup_or_add(ConstantInt::getFalse());
- }
-
- uint32_t getTrueVN() { return true_vn; }
- uint32_t getFalseVN() { return false_vn; }
-
+ ValueTable() : nextValueNumber(1) { }
uint32_t lookup_or_add(Value* V);
uint32_t lookup(Value* V) const;
void add(Value* V, uint32_t num);
@@ -1302,27 +1294,9 @@
uint32_t nextNum = VN.getNextUnusedValueNumber();
unsigned num = VN.lookup_or_add(I);
- if (BranchInst* BI = dyn_cast<BranchInst>(I)) {
- localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
-
- if (!BI->isConditional() || isa<Constant>(BI->getCondition()))
- return false;
-
- Value* branchCond = BI->getCondition();
- uint32_t condVN = VN.lookup_or_add(branchCond);
-
- BasicBlock* trueSucc = BI->getSuccessor(0);
- BasicBlock* falseSucc = BI->getSuccessor(1);
-
- localAvail[trueSucc]->table.insert(std::make_pair(condVN,
- ConstantInt::getTrue()));
- localAvail[falseSucc]->table.insert(std::make_pair(condVN,
- ConstantInt::getFalse()));
- return false;
-
// Allocations are always uniquely numbered, so we can save time and memory
- // by fast failing them.
- } else if (isa<AllocationInst>(I) || isa<TerminatorInst>(I)) {
+ // by fast failing them.
+ if (isa<AllocationInst>(I) || isa<TerminatorInst>(I)) {
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
return false;
}
@@ -1431,11 +1405,18 @@
bool GVN::processBlock(BasicBlock* BB) {
+ DomTreeNode* DTN = DT->getNode(BB);
// FIXME: Kill off toErase by doing erasing eagerly in a helper function (and
// incrementing BI before processing an instruction).
SmallVector<Instruction*, 8> toErase;
bool changed_function = false;
+ if (DTN->getIDom())
+ localAvail[BB] =
+ new ValueNumberScope(localAvail[DTN->getIDom()->getBlock()]);
+ else
+ localAvail[BB] = new ValueNumberScope(0);
+
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
BI != BE;) {
changed_function |= processInstruction(BI, toErase);
@@ -1626,15 +1607,6 @@
bool GVN::iterateOnFunction(Function &F) {
cleanupGlobalSets();
- for (df_iterator<DomTreeNode*> DI = df_begin(DT->getRootNode()),
- DE = df_end(DT->getRootNode()); DI != DE; ++DI) {
- if (DI->getIDom())
- localAvail[DI->getBlock()] =
- new ValueNumberScope(localAvail[DI->getIDom()->getBlock()]);
- else
- localAvail[DI->getBlock()] = new ValueNumberScope(0);
- }
-
// Top-down walk of the dominator tree
bool changed = false;
#if 0
Removed: llvm/trunk/test/Transforms/GVN/condprop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/condprop.ll?rev=68210&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GVN/condprop.ll (original)
+++ llvm/trunk/test/Transforms/GVN/condprop.ll (removed)
@@ -1,52 +0,0 @@
-; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {br i1 false}
-
- at a = external global i32 ; <i32*> [#uses=7]
-
-define i32 @foo() nounwind {
-entry:
- %0 = load i32* @a, align 4 ; <i32> [#uses=1]
- %1 = icmp eq i32 %0, 4 ; <i1> [#uses=1]
- br i1 %1, label %bb, label %bb1
-
-bb: ; preds = %entry
- br label %bb8
-
-bb1: ; preds = %entry
- %2 = load i32* @a, align 4 ; <i32> [#uses=1]
- %3 = icmp eq i32 %2, 5 ; <i1> [#uses=1]
- br i1 %3, label %bb2, label %bb3
-
-bb2: ; preds = %bb1
- br label %bb8
-
-bb3: ; preds = %bb1
- %4 = load i32* @a, align 4 ; <i32> [#uses=1]
- %5 = icmp eq i32 %4, 4 ; <i1> [#uses=1]
- br i1 %5, label %bb4, label %bb5
-
-bb4: ; preds = %bb3
- %6 = load i32* @a, align 4 ; <i32> [#uses=1]
- %7 = add i32 %6, 5 ; <i32> [#uses=1]
- br label %bb8
-
-bb5: ; preds = %bb3
- %8 = load i32* @a, align 4 ; <i32> [#uses=1]
- %9 = icmp eq i32 %8, 5 ; <i1> [#uses=1]
- br i1 %9, label %bb6, label %bb7
-
-bb6: ; preds = %bb5
- %10 = load i32* @a, align 4 ; <i32> [#uses=1]
- %11 = add i32 %10, 4 ; <i32> [#uses=1]
- br label %bb8
-
-bb7: ; preds = %bb5
- %12 = load i32* @a, align 4 ; <i32> [#uses=1]
- br label %bb8
-
-bb8: ; preds = %bb7, %bb6, %bb4, %bb2, %bb
- %.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ] ; <i32> [#uses=1]
- br label %return
-
-return: ; preds = %bb8
- ret i32 %.0
-}
More information about the llvm-commits
mailing list