[PATCH] D148414: [InstCombine] Expand `foldSelectICmpAndOr` -> `foldSelectICmpAndBinOp` to work for any binop

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 00:12:46 PDT 2023


goldstein.w.n added a comment.

In D148414#4290852 <https://reviews.llvm.org/D148414#4290852>, @nikic wrote:

> In D148414#4290790 <https://reviews.llvm.org/D148414#4290790>, @goldstein.w.n wrote:
>
>> 2. Update `foldSelectIntoOp` to do constants iff `isPow2(abs(TC - FC))` and `Cond` is  either `(ICmp eq Pow2OrZero, C_Pow2)` or a SignTest
>
> Ideally we would just remove the limitation entirely -- at the IR level, we would certainly prefer having a select on constants. However, this would likely need a backend undo transform, because that saves materializing the zero constant and likely allows folding the other constant into an immediate operand.

@nikic so the backend has code to undo this already. Its just not enabled for scalars. I enabled it on a branch for x86 here:
https://github.com/goldsteinn/llvm-project/pull/new/enable-select-backend        
but a lot of regressions. Maybe simpler to just handle the known cases here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148414



More information about the llvm-commits mailing list