llvm.org GIT mirror llvm / e63c4a2
Revert r68172. It caused regressions in Applications/Burg/burg Applications/ClamAV/clamscan and many other tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68211 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
2 changed file(s) with 10 addition(s) and 90 deletion(s). Raw diff Collapse all Expand all
120120 AliasAnalysis* AA;
121121 MemoryDependenceAnalysis* MD;
122122 DominatorTree* DT;
123 uint32_t true_vn, false_vn;
124123
125124 uint32_t nextValueNumber;
126125
138137 Expression create_expression(CallInst* C);
139138 Expression create_expression(Constant* C);
140139 public:
141 ValueTable() : nextValueNumber(1) {
142 true_vn = lookup_or_add(ConstantInt::getTrue());
143 false_vn = lookup_or_add(ConstantInt::getFalse());
144 }
145
146 uint32_t getTrueVN() { return true_vn; }
147 uint32_t getFalseVN() { return false_vn; }
148
140 ValueTable() : nextValueNumber(1) { }
149141 uint32_t lookup_or_add(Value* V);
150142 uint32_t lookup(Value* V) const;
151143 void add(Value* V, uint32_t num);
13011293 uint32_t nextNum = VN.getNextUnusedValueNumber();
13021294 unsigned num = VN.lookup_or_add(I);
13031295
1304 if (BranchInst* BI = dyn_cast(I)) {
1305 localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
1306
1307 if (!BI->isConditional() || isa(BI->getCondition()))
1308 return false;
1309
1310 Value* branchCond = BI->getCondition();
1311 uint32_t condVN = VN.lookup_or_add(branchCond);
1312
1313 BasicBlock* trueSucc = BI->getSuccessor(0);
1314 BasicBlock* falseSucc = BI->getSuccessor(1);
1315
1316 localAvail[trueSucc]->table.insert(std::make_pair(condVN,
1317 ConstantInt::getTrue()));
1318 localAvail[falseSucc]->table.insert(std::make_pair(condVN,
1319 ConstantInt::getFalse()));
1320 return false;
1321
13221296 // Allocations are always uniquely numbered, so we can save time and memory
1323 // by fast failing them.
1324 } else if (isa(I) || isa(I)) {
1297 // by fast failing them.
1298 if (isa(I) || isa(I)) {
13251299 localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
13261300 return false;
13271301 }
14301404
14311405
14321406 bool GVN::processBlock(BasicBlock* BB) {
1407 DomTreeNode* DTN = DT->getNode(BB);
14331408 // FIXME: Kill off toErase by doing erasing eagerly in a helper function (and
14341409 // incrementing BI before processing an instruction).
14351410 SmallVector toErase;
14361411 bool changed_function = false;
1412
1413 if (DTN->getIDom())
1414 localAvail[BB] =
1415 new ValueNumberScope(localAvail[DTN->getIDom()->getBlock()]);
1416 else
1417 localAvail[BB] = new ValueNumberScope(0);
14371418
14381419 for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
14391420 BI != BE;) {
16251606 bool GVN::iterateOnFunction(Function &F) {
16261607 cleanupGlobalSets();
16271608
1628 for (df_iterator DI = df_begin(DT->getRootNode()),
1629 DE = df_end(DT->getRootNode()); DI != DE; ++DI) {
1630 if (DI->getIDom())
1631 localAvail[DI->getBlock()] =
1632 new ValueNumberScope(localAvail[DI->getIDom()->getBlock()]);
1633 else
1634 localAvail[DI->getBlock()] = new ValueNumberScope(0);
1635 }
1636
16371609 // Top-down walk of the dominator tree
16381610 bool changed = false;
16391611 #if 0
+0
-52
test/Transforms/GVN/condprop.ll less more
None ; RUN: llvm-as < %s | opt -gvn | llvm-dis | grep {br i1 false}
1
2 @a = external global i32 ; [#uses=7]
3
4 define i32 @foo() nounwind {
5 entry:
6 %0 = load i32* @a, align 4 ; [#uses=1]
7 %1 = icmp eq i32 %0, 4 ; [#uses=1]
8 br i1 %1, label %bb, label %bb1
9
10 bb: ; preds = %entry
11 br label %bb8
12
13 bb1: ; preds = %entry
14 %2 = load i32* @a, align 4 ; [#uses=1]
15 %3 = icmp eq i32 %2, 5 ; [#uses=1]
16 br i1 %3, label %bb2, label %bb3
17
18 bb2: ; preds = %bb1
19 br label %bb8
20
21 bb3: ; preds = %bb1
22 %4 = load i32* @a, align 4 ; [#uses=1]
23 %5 = icmp eq i32 %4, 4 ; [#uses=1]
24 br i1 %5, label %bb4, label %bb5
25
26 bb4: ; preds = %bb3
27 %6 = load i32* @a, align 4 ; [#uses=1]
28 %7 = add i32 %6, 5 ; [#uses=1]
29 br label %bb8
30
31 bb5: ; preds = %bb3
32 %8 = load i32* @a, align 4 ; [#uses=1]
33 %9 = icmp eq i32 %8, 5 ; [#uses=1]
34 br i1 %9, label %bb6, label %bb7
35
36 bb6: ; preds = %bb5
37 %10 = load i32* @a, align 4 ; [#uses=1]
38 %11 = add i32 %10, 4 ; [#uses=1]
39 br label %bb8
40
41 bb7: ; preds = %bb5
42 %12 = load i32* @a, align 4 ; [#uses=1]
43 br label %bb8
44
45 bb8: ; preds = %bb7, %bb6, %bb4, %bb2, %bb
46 %.0 = phi i32 [ %12, %bb7 ], [ %11, %bb6 ], [ %7, %bb4 ], [ 4, %bb2 ], [ 5, %bb ] ; [#uses=1]
47 br label %return
48
49 return: ; preds = %bb8
50 ret i32 %.0
51 }