[PATCH] D11648: InstCombinePHI: Partial simplification of identity operations
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 19:29:35 PDT 2015
majnemer added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombinePHI.cpp:850-855
@@ +849,8 @@
+ // since it's not obvious if that'd be a performance win and if it'd be safe.
+ if (const auto *BI = dyn_cast<BranchInst>(Terminator)) {
+ if (BI->isConditional() && (PNUser.getOpcode() == Instruction::UDiv ||
+ PNUser.getOpcode() == Instruction::SDiv))
+ return nullptr;
+ } else
+ return nullptr;
+
----------------
I think the correct logic would be:
// We can only push the instruction to a predecessor if our predecessor is guaranteed to have a single, unique successor.
if (BB->getUniqueSuccessor() != PN.getParent())
return nullptr;
It should always be safe to hoist the instruction so long as it is inserted before the terminator.
Repository:
rL LLVM
http://reviews.llvm.org/D11648
More information about the llvm-commits
mailing list