diff options
author | Marius Kamp <msk@posteo.org> | 2025-06-10 18:12:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-10 17:12:10 +0100 |
commit | 30cabdda45a0f2e48aaa19bded9de9bb50bb83cb (patch) | |
tree | e00b941963fffea62e21a606bc746737b4e2b805 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 94c241614f491c0cd832614bde6130e315e53467 (diff) | |
download | llvm-30cabdda45a0f2e48aaa19bded9de9bb50bb83cb.zip llvm-30cabdda45a0f2e48aaa19bded9de9bb50bb83cb.tar.gz llvm-30cabdda45a0f2e48aaa19bded9de9bb50bb83cb.tar.bz2 |
[X86] Distribute Certain Bitwise Operations over SELECT (#136555)
InstCombine canonicalizes `(select P (and X (- X)) X)` to
`(and (select P (- X) umax) X)`. This is counterproductive for the X86
backend when BMI is available because we can encode `(and X (- X))`
using the `BLSI` instruction. A similar situation arises if we have
`(select P (and X (sub X 1)) X)` (prevents use of `BLSR` instruction) or
`(select P (xor X (sub X 1)) X)` (prevents use of `BLSMSK` instruction).
Trigger the inverse transformation in the X86 backend if BMI is
available and we can use the mentioned BMI instructions. This is done by
overriding the appropriate `shouldFoldSelectWithIdentityConstant()`
overload. In this way, we get `(select P (and X (- X)) X)` again, which
enables the use of `BLSI` (similar for the other cases described above).
Alive proofs: https://alive2.llvm.org/ce/z/MT_pKi
Fixes #131587, fixes #133848.
---------
Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions