[PATCH] D117110: [InstCombine] try to fold binop with phi operands
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 12 17:38:45 PST 2022
luna added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:1329-1334
+ Builder.SetInsertPoint(PredBlockBranch);
+ Value *NewBO = Builder.CreateBinOp(BO.getOpcode(),
+ Phi0->getIncomingValueForBlock(OtherBB),
+ Phi1->getIncomingValueForBlock(OtherBB));
+ if (auto *NotFoldedNewBO = dyn_cast<BinaryOperator>(NewBO))
+ NotFoldedNewBO->copyIRFlags(&BO);
----------------
I'm wondering if it's idiomatic to validate that this instruction could also be simplified away in later iterations of instruction-combine, and only proceed with the fold if yes.
e.g., in https://godbolt.org/z/fKfondqrn, `%res = or i64 %retval.sroa.3.0.extract.shift, %phi.cast` instruction is inserted into `if.then` block, and could be simplified away.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117110/new/
https://reviews.llvm.org/D117110
More information about the llvm-commits
mailing list