[PATCH] D28117: [NewGVN] Merge conditional branches before value numbering
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 26 06:09:33 PST 2016
davide created this revision.
davide added a reviewer: dberlin.
davide added a subscriber: llvm-commits.
We're discussing it in https://llvm.org/bugs/show_bug.cgi?id=31468
Patch on phab for easier reviews.
https://reviews.llvm.org/D28117
Files:
lib/Transforms/Scalar/NewGVN.cpp
test/Transforms/NewGVN/basic.ll
Index: test/Transforms/NewGVN/basic.ll
===================================================================
--- test/Transforms/NewGVN/basic.ll
+++ test/Transforms/NewGVN/basic.ll
@@ -1,4 +1,3 @@
-; XFAIL: *
; RUN: opt < %s -newgvn -S | FileCheck %s
define i32 @main() {
Index: lib/Transforms/Scalar/NewGVN.cpp
===================================================================
--- lib/Transforms/Scalar/NewGVN.cpp
+++ lib/Transforms/Scalar/NewGVN.cpp
@@ -1378,6 +1378,20 @@
unsigned ICount = 0;
SmallPtrSet<BasicBlock *, 16> VisitedBlocks;
+ // Do a sweep over all the basic blocks to merge unconditional branches.
+ for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
+ BasicBlock *BB = &*FI++;
+
+ // In theory here we could pass MemSSA if/when MergeBlockIntoPredecessor
+ // will grow version which accepts the analysis.
+ bool removedBlock = MergeBlockIntoPredecessor(
+ BB, DT, nullptr /* LoopInfo */, nullptr /* MemDep */);
+
+ if (removedBlock)
+ NumGVNBlocksDeleted++;
+ Changed |= removedBlock;
+ }
+
// Note: We want RPO traversal of the blocks, which is not quite the same as
// dominator tree order, particularly with regard whether backedges get
// visited first or second, given a block with multiple successors.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28117.82498.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161226/6a9ff93f/attachment.bin>
More information about the llvm-commits
mailing list