https://llvm.org/bugs/show_bug.cgi?id=31468
Bug ID: 31468 Summary: NewGVN doesn't merge unconditional branches. Product: libraries Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: dav...@freebsd.org Reporter: dav...@freebsd.org CC: dber...@dberlin.org, llvm-bugs@lists.llvm.org Blocks: 30995 Classification: Unclassified The code living in GVN.cpp claims this is done to expose "more PRE opportunities". Fair enough, but I'm not entirely sure this is relevant anymore in NewGVN as we're writing a real PRE infrastructure. Fixing is relatively trivial (patch inline), but not sure if really needed. Dan, what you think? If we don't want to change this code, I'll modify the failing test and call it a day (basic.ll) diff --git a/lib/Transforms/Scalar/NewGVN.cpp b/lib/Transforms/Scalar/NewGVN.cpp index 1f12d10..430385a 100644 --- a/lib/Transforms/Scalar/NewGVN.cpp +++ b/lib/Transforms/Scalar/NewGVN.cpp @@ -1378,6 +1378,20 @@ bool NewGVN::runGVN(Function &F, DominatorTree *_DT, AssumptionCache *_AC, 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. diff --git a/test/Transforms/NewGVN/basic.ll b/test/Transforms/NewGVN/basic.ll index f6670aa..f68823a 100644 --- a/test/Transforms/NewGVN/basic.ll +++ b/test/Transforms/NewGVN/basic.ll @@ -1,4 +1,3 @@ -; XFAIL: * ; RUN: opt < %s -newgvn -S | FileCheck %s define i32 @main() { -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs