[all-commits] [llvm/llvm-project] 30cabd: [X86] Distribute Certain Bitwise Operations over S...
Marius Kamp via All-commits
all-commits at lists.llvm.org
Tue Jun 10 09:12:33 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 30cabdda45a0f2e48aaa19bded9de9bb50bb83cb
https://github.com/llvm/llvm-project/commit/30cabdda45a0f2e48aaa19bded9de9bb50bb83cb
Author: Marius Kamp <msk at posteo.org>
Date: 2025-06-10 (Tue, 10 Jun 2025)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
A llvm/test/CodeGen/X86/bmi-select-distrib.ll
Log Message:
-----------
[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 at redking.me.uk>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list