[PATCH] D16240: [InstCombine] Simplify a known nonzero incoming value of PHI
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 10 21:22:09 PST 2016
sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.
LGTM with minor nits inline.
================
Comment at: lib/Transforms/InstCombine/InstCombinePHI.cpp:651
@@ +650,3 @@
+ assert(isa<IntegerType>(PN->getType()) && "Expect only intger type phi");
+ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
+ if (ConstantInt *ConstVA = dyn_cast<ConstantInt>(PN->getIncomingValue(i)))
----------------
Use `for (Value *V : PN.operands())` here.
================
Comment at: lib/Transforms/InstCombine/InstCombinePHI.cpp:652
@@ +651,3 @@
+ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
+ if (ConstantInt *ConstVA = dyn_cast<ConstantInt>(PN->getIncomingValue(i)))
+ if (!ConstVA->isZeroValue())
----------------
Use `auto *ConstVA` here.
================
Comment at: lib/Transforms/InstCombine/InstCombinePHI.cpp:953
@@ +952,3 @@
+ if (!NonZeroConst)
+ NonZeroConst = GetAnyNonZeroConstInt(&PN);
+ PN.setIncomingValue(i, NonZeroConst);
----------------
I'd just pass `PN` by reference here (and change `GetAnyNonZeroConstInt` to take `PHINode &`).
http://reviews.llvm.org/D16240
More information about the llvm-commits
mailing list