|
Revision tags: llvmorg-21-init |
|
| #
d76ea250 |
| 28-Jan-2025 |
Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> |
Reland [InstCombine] Teach foldSelectOpOp about samesign (#124320)
Changes: There was a serious bug in the previous patch, leading to a
miscompile. See #122723 for the miscompile report from Alexan
Reland [InstCombine] Teach foldSelectOpOp about samesign (#124320)
Changes: There was a serious bug in the previous patch, leading to a
miscompile. See #122723 for the miscompile report from Alexander, and
the follow-up investigation by Nikita. The patch has since been
reworked, and now includes the testcase from the miscompile.
Follow up on 4a0d53a (PatternMatch: migrate to CmpPredicate) to get rid
of one of the FIXMEs it introduced by replacing a predicate comparison
with CmpPredicate::getMatching.
Co-authored-by: Nikita Popov <npopov@redhat.com>
show more ...
|
| #
78831848 |
| 24-Jan-2025 |
Alexander Kornienko <alexfh@google.com> |
Revert "[InstCombine] Teach foldSelectOpOp about samesign" (#124123)
Reverts llvm/llvm-project#122723 due to a miscompilation
See
https://github.com/llvm/llvm-project/pull/122723#issuecomment-26
Revert "[InstCombine] Teach foldSelectOpOp about samesign" (#124123)
Reverts llvm/llvm-project#122723 due to a miscompilation
See
https://github.com/llvm/llvm-project/pull/122723#issuecomment-2608777844
for details and the test case.
show more ...
|
| #
48757e02 |
| 14-Jan-2025 |
Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> |
[InstCombine] Teach foldSelectOpOp about samesign (#122723)
Follow up on 4a0d53a (PatternMatch: migrate to CmpPredicate) to get rid
of one of the FIXMEs it introduced by replacing a predicate compa
[InstCombine] Teach foldSelectOpOp about samesign (#122723)
Follow up on 4a0d53a (PatternMatch: migrate to CmpPredicate) to get rid
of one of the FIXMEs it introduced by replacing a predicate comparison
with CmpPredicate::getMatching.
show more ...
|
|
Revision tags: llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3 |
|
| #
aad3a163 |
| 16-Oct-2024 |
Yingwei Zheng <dtcxzyw2333@gmail.com> |
[ValueTracking] Respect `samesign` flag in `isKnownInversion` (#112390)
In https://github.com/llvm/llvm-project/pull/93591 we introduced
`isKnownInversion` and assumes `X` is poison implies `Y` is
[ValueTracking] Respect `samesign` flag in `isKnownInversion` (#112390)
In https://github.com/llvm/llvm-project/pull/93591 we introduced
`isKnownInversion` and assumes `X` is poison implies `Y` is poison
because they share common operands. But after introducing `samesign`
this assumption no longer hold if `X` is an icmp has `samesign` flag.
Alive2 link: https://alive2.llvm.org/ce/z/rj3EwQ (Please run it locally
with this patch and https://github.com/AliveToolkit/alive2/pull/1098).
This approach is the most conservative way in my mind to address this
problem. If `X` has `samesign` flag, it will check if `Y` also has this
flag and make sure constant RHS operands have the same sign.
Fixes https://github.com/llvm/llvm-project/issues/112350.
show more ...
|
|
Revision tags: llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4 |
|
| #
de2b6cb6 |
| 22-Aug-2024 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Fold icmp over select of cmp more aggressively (#105536)
When folding an icmp into a select, treat an icmp of a constant with a
one-use ucmp/scmp intrinsic as a simplification. These
[InstCombine] Fold icmp over select of cmp more aggressively (#105536)
When folding an icmp into a select, treat an icmp of a constant with a
one-use ucmp/scmp intrinsic as a simplification. These comparisons will
reduce down to an icmp.
This addresses a regression seen in Rust and also in llvm-opt-benchmark.
show more ...
|
| #
3c8f139f |
| 21-Aug-2024 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Add tests for icmp of select of cmp (NFC)
|
| #
a1058776 |
| 21-Aug-2024 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Remove some of the complexity-based canonicalization (#91185)
The idea behind this canonicalization is that it allows us to handle less
patterns, because we know that some will be can
[InstCombine] Remove some of the complexity-based canonicalization (#91185)
The idea behind this canonicalization is that it allows us to handle less
patterns, because we know that some will be canonicalized away. This is
indeed very useful to e.g. know that constants are always on the right.
However, this is only useful if the canonicalization is actually
reliable. This is the case for constants, but not for arguments: Moving
these to the right makes it look like the "more complex" expression is
guaranteed to be on the left, but this is not actually the case in
practice. It fails as soon as you replace the argument with another
instruction.
The end result is that it looks like things correctly work in tests,
while they actually don't. We use the "thwart complexity-based
canonicalization" trick to handle this in tests, but it's often a
challenge for new contributors to get this right, and based on the
regressions this PR originally exposed, we clearly don't get this right
in many cases.
For this reason, I think that it's better to remove this complexity
canonicalization. It will make it much easier to write tests for
commuted cases and make sure that they are handled.
show more ...
|
|
Revision tags: llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7 |
|
| #
0a39c88e |
| 04-Jun-2024 |
Yingwei Zheng <dtcxzyw2333@gmail.com> |
[InstCombine] Fold `select Cond, not X, X` into `Cond ^ X` (#93591)
See the following example:
```
define i1 @src(i64 %x, i1 %y) {
%1526 = icmp ne i64 %x, 0
%1527 = icmp eq i64 %x, 0
%sel
[InstCombine] Fold `select Cond, not X, X` into `Cond ^ X` (#93591)
See the following example:
```
define i1 @src(i64 %x, i1 %y) {
%1526 = icmp ne i64 %x, 0
%1527 = icmp eq i64 %x, 0
%sel = select i1 %y, i1 %1526, i1 %1527
ret i1 %sel
}
define i1 @tgt(i64 %x, i1 %y) {
%1527 = icmp eq i64 %x, 0
%sel = xor i1 %y, %1527
ret i1 %sel
}
```
I find that this pattern is common in C/C++/Rust code base.
This patch folds `select Cond, Y, X` into `Cond ^ X` iff:
1. X has the same type as Cond
2. X is poison -> Y is poison
3. X == !Y
Alive2: https://alive2.llvm.org/ce/z/hSmkHS
show more ...
|
|
Revision tags: llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7 |
|
| #
b4c8cfc7 |
| 07-Dec-2022 |
chenglin.bi <chenglin.bi@linaro.org> |
[InstCombine] fold more icmp + select patterns by distributive laws
follow up D139076, add icmp with not only eq/ne, but also gt/lt/ge/le.
Reviewed By: spatel
Differential Revision: https://review
[InstCombine] fold more icmp + select patterns by distributive laws
follow up D139076, add icmp with not only eq/ne, but also gt/lt/ge/le.
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D139253
show more ...
|
| #
b966fb08 |
| 05-Dec-2022 |
chenglin.bi <chenglin.bi@linaro.org> |
[InstCombine] Precommit tests for D139253; NFC
|
| #
e719550e |
| 02-Dec-2022 |
chenglin.bi <chenglin.bi@linaro.org> |
[InstCombine] fold icmp + select pattern by distributive laws
`C ? (Y != X) : (Z != X) --> (C ? Y : Z) != X` `C ? (Y == X) : (Z == X) --> (C ? Y : Z) == X`
https://alive2.llvm.org/ce/z/-frXfs
Revi
[InstCombine] fold icmp + select pattern by distributive laws
`C ? (Y != X) : (Z != X) --> (C ? Y : Z) != X` `C ? (Y == X) : (Z == X) --> (C ? Y : Z) == X`
https://alive2.llvm.org/ce/z/-frXfs
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D139076
show more ...
|
| #
6a70b846 |
| 02-Dec-2022 |
chenglin.bi <chenglin.bi@linaro.org> |
[InstCombine] Precommit tests for D139076; NFC
|
|
Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2 |
|
| #
40a2e355 |
| 26-Apr-2022 |
Juneyoung Lee <aqjune@gmail.com> |
[InstCombine] Remove the undef-related workaround code in visitSelectInst
This patch removes an old hack in visitSelectInst that was written to avoid miscompilation bugs in loop unswitch. (Added via
[InstCombine] Remove the undef-related workaround code in visitSelectInst
This patch removes an old hack in visitSelectInst that was written to avoid miscompilation bugs in loop unswitch. (Added via https://reviews.llvm.org/D35811)
The legacy loop unswitch pass will be removed after D124376, and the new simple loop unswitch pass correctly uses freeze to avoid introducing UB after D124252.
Since the hack is not necessary anymore, this patch removes it.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D124426
show more ...
|
| #
112e3d86 |
| 27-Apr-2022 |
Juneyoung Lee <aqjune@gmail.com> |
Add a pre-commit test for D124426
|