[PATCH] D152281: [Transforms][LICM] Add the ability to undo unprofitable reassociation
Paul Osmialowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 08:10:36 PDT 2023
pawosm01 marked an inline comment as done.
pawosm01 added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2725
+ if (Use *U =
+ Ops[L.isLoopInvariant(Ops[0]) ? 0 : 1]->getSingleUndroppableUse())
+ Changes.push_back(U);
----------------
nikic wrote:
> This should be `&Op->getOperandUse(Ops[L.isLoopInvariant(Ops[0]) ? 0 : 1])` or so. But I think it would be less awkward to do something like this, so you don't go back and forth between operand indices, Values and Uses:
>
> ```
> if (Op->getOpcode() != Instruction::FMul) {
> if (OpNext->getOpcode() != Instruction::FMul)
> return false;
> std::swap(Op, OpNext);
> }
> if (!Op->hasOneUse() || !Op->hasAllowReassoc() || L.isLoopInvariant(Op))
> return false;
> Use &U0 = Op->getOperandUse(0);
> Use &U1 = Op->getOperandUse(1);
> if (L.isLoopInvariant(U0))
> Changes.push_back(&U0);
> else if (L.isLoopInvariant(U1))
> Changes.push_back(&U1);
> else
> return false;
> ```
ok, thanks for your valuable input.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152281/new/
https://reviews.llvm.org/D152281
More information about the llvm-commits
mailing list