Index: lib/Transforms/Scalar/NewGVN.cpp =================================================================== --- lib/Transforms/Scalar/NewGVN.cpp +++ lib/Transforms/Scalar/NewGVN.cpp @@ -1378,6 +1378,20 @@ unsigned ICount = 0; SmallPtrSet 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 a 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. 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() {