From 00e7558edde5ce7d065468b40167a5f31f0a44be Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 21 Aug 2018 23:42:38 +0000 Subject: [PATCH] [CodeGenPrepare] Scan past debug intrinsics to find select candidates (NFC) In optimizeSelectInst, when scanning for candidate selects to rewrite into branches, scan past debug intrinsics. This makes the debug-enabled and non-debug paths through optimizeSelectInst more congruent. NFC because every select is eventually visited either way. llvm-svn: 340368 --- llvm/lib/CodeGen/CodeGenPrepare.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 2478f95..7d7d48b 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -5599,9 +5599,10 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) { // Find all consecutive select instructions that share the same condition. SmallVector ASI; ASI.push_back(SI); - for (BasicBlock::iterator It = ++BasicBlock::iterator(SI); - It != SI->getParent()->end(); ++It) { - SelectInst *I = dyn_cast(&*It); + for (Instruction *NextInst = SI->getNextNonDebugInstruction(); + NextInst != SI->getParent()->getTerminator(); + NextInst = NextInst->getNextNonDebugInstruction()) { + SelectInst *I = dyn_cast(NextInst); if (I && SI->getCondition() == I->getCondition()) { ASI.push_back(I); } else { -- 2.7.4