[PATCH] D156620: [InstCombine] Improve foldOpIntoPhi() to use isImpliedCondition
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 30 12:51:16 PDT 2023
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:1364
+ const Value *RHSOp0 = Ops[0];
+ const Value *RHSOp1 = Ops[1];
+ bool LHSIsTrue = TerminatorBI->getSuccessor(0) == PN->getParent();
----------------
I don't think the RHSOp0, RHSOp1 variables really add value over Ops[0], Ops[1] here.
================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:1365
+ const Value *RHSOp1 = Ops[1];
+ bool LHSIsTrue = TerminatorBI->getSuccessor(0) == PN->getParent();
+ std::optional<bool> ImpliedCond =
----------------
I think your tests currently only cover one of the LHSIsTrue cases. You also need one with successors swapped.
================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:1372
+ NewPhiValues.push_back(
+ ConstantVector::getIntegerValue(I.getType(), Constant));
+ continue;
----------------
You can use `ConstantInt::getBool()` here.
================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:1383
&I, Ops, SQ.getWithInstruction(InBB->getTerminator()));
if (NewVal && NewVal != PN && !match(NewVal, m_ConstantExpr())) {
NewPhiValues.push_back(NewVal);
----------------
Please extract the code above here into a separate function (which does simplifyInstructionWithOperands plus the special icmp case).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156620/new/
https://reviews.llvm.org/D156620
More information about the llvm-commits
mailing list