[PATCH] D146350: [InstCombine] More aggressively try and fold irem/idiv/mul into selects.

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 13:10:49 PDT 2023


goldstein.w.n added a comment.

In D146350#4313194 <https://reviews.llvm.org/D146350#4313194>, @xbolva00 wrote:

> We generally fail to call 'foldBinOpIntoSelectOrPhi' in commonIDivTransforms and commonIRemTransforms
>
> How hard would be to add support for PHIs in your shouldFoldOp helper? (Can be followup).

Well we match explicitly against `m_Select(...)` to check the all constant case so that wouldn't apply.
The speculative execution check can be reused, however.

Personally to add PHI support I'd create a new function "shouldFoldOpIntoX(...)" then have a variant
for select/phi and base the imm match on what X is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146350/new/

https://reviews.llvm.org/D146350



More information about the llvm-commits mailing list