[all-commits] [llvm/llvm-project] 703401: [InstCombine] Combine or-disjoint (and->mul), (and...
Jeffrey Byrnes via All-commits
all-commits at lists.llvm.org
Wed Jun 11 18:07:22 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7034014d08249a1e159a668a71e96a0b78636a39
https://github.com/llvm/llvm-project/commit/7034014d08249a1e159a668a71e96a0b78636a39
Author: Jeffrey Byrnes <jeffrey.byrnes at amd.com>
Date: 2025-06-11 (Wed, 11 Jun 2025)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
M llvm/test/Transforms/InstCombine/or-bitmask.ll
Log Message:
-----------
[InstCombine] Combine or-disjoint (and->mul), (and->mul) to and->mul (#136013)
The canonical pattern for bitmasked mul is currently
```
%val = and %x, %bitMask // where %bitMask is some constant
%cmp = icmp eq %val, 0
%sel = select %cmp, 0, %C // where %C is some constant = C' * %bitMask
```
In certain cases, where we are combining multiple of these bitmasked
muls with common factors, we are able to optimize into and->mul (see
https://github.com/llvm/llvm-project/pull/135274 )
This optimization lends itself to further optimizations. This PR
addresses one of such optimizations.
In cases where we have
`or-disjoint ( mul(and (X, C1), D) , mul (and (X, C2), D))`
we can combine into
`mul( and (X, (C1 + C2)), D) `
provided C1 and C2 are disjoint.
Generalized proof: https://alive2.llvm.org/ce/z/MQYMui
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