|
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5 |
|
| #
56c091ea |
| 21-Nov-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
This brings the printing of scalable vector constant splats inline with
their fixed length counterparts.
|
|
Revision tags: llvmorg-19.1.4 |
|
| #
97298853 |
| 13-Nov-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][IR] Teach constant integer binop folds about vector ConstantInts. (#115739)
The existing logic mostly works with the main changes being:
* Use getScalarSizeInBits instead of IntegerType::ge
[LLVM][IR] Teach constant integer binop folds about vector ConstantInts. (#115739)
The existing logic mostly works with the main changes being:
* Use getScalarSizeInBits instead of IntegerType::getBitWidth
* Use ConstantInt::get(Type* instead of ConstantInt::get(LLVMContext
show more ...
|
| #
38fffa63 |
| 06-Nov-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][IR] Use splat syntax when printing Constant[Data]Vector. (#112548)
|
| #
a77dedca |
| 01-Nov-2024 |
Yingwei Zheng <dtcxzyw2333@gmail.com> |
[InstSimplify][InstCombine][ConstantFold] Move vector div/rem by zero fold to InstCombine (#114280)
Previously we fold `div/rem X, C` into `poison` if any element of the
constant divisor `C` is zer
[InstSimplify][InstCombine][ConstantFold] Move vector div/rem by zero fold to InstCombine (#114280)
Previously we fold `div/rem X, C` into `poison` if any element of the
constant divisor `C` is zero or undef. However, it is incorrect when
threading udiv over an vector select:
https://alive2.llvm.org/ce/z/3Ninx5
```
define <2 x i32> @vec_select_udiv_poison(<2 x i1> %x) {
%sel = select <2 x i1> %x, <2 x i32> <i32 -1, i32 -1>, <2 x i32> <i32 0, i32 1>
%div = udiv <2 x i32> <i32 42, i32 -7>, %sel
ret <2 x i32> %div
}
```
In this case, `threadBinOpOverSelect` folds `udiv <i32 42, i32 -7>, <i32
-1, i32 -1>` and `udiv <i32 42, i32 -7>, <i32 0, i32 1>` into
`zeroinitializer` and `poison`, respectively. One solution is to
introduce a new flag indicating that we are threading over a vector
select. But it requires to modify both `InstSimplify` and
`ConstantFold`.
However, this optimization doesn't provide benefits to real-world
programs:
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/IR/ConstantFold.cpp.html#L908
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp.html#L1107
This patch moves the fold into InstCombine to avoid breaking numerous
existing tests.
Fixes #114191 and #113866 (only poison-safety issue).
show more ...
|
|
Revision tags: llvmorg-19.1.3 |
|
| #
5d4a0d54 |
| 27-Oct-2024 |
David Majnemer <david.majnemer@gmail.com> |
[InstCombine] Teach takeLog2 about right shifts, truncation and bitwise-and
We left some easy opportunities for further simplifications.
log2(trunc(x)) is simply trunc(log2(x)). This is safe if we
[InstCombine] Teach takeLog2 about right shifts, truncation and bitwise-and
We left some easy opportunities for further simplifications.
log2(trunc(x)) is simply trunc(log2(x)). This is safe if we know that trunc is NUW because it means that the truncation didn't drop any bits. It is also safe if the caller is OK with zero as a possible answer.
log2(x >>u y) is simply `log2(x) - y`.
log2(x & y) is a funny one. It comes up when doing something like: ``` unsigned int f(unsigned int x, unsigned int y) { unsigned char a = 1u << x; return y / a; } ```
LLVM would canonicalize this to: ``` %shl = shl nuw i32 1, %x %conv1 = and i32 %shl, 255 %div = udiv i32 %y, %conv1 ```
In cases like these, we can ignore the mask entirely. This is equivalent to `y >> x`.
show more ...
|
|
Revision tags: llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, 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, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3 |
|
| #
b3ee127e |
| 21-Mar-2024 |
Noah Goldstein <goldstein.w.n@gmail.com> |
[InstCombine] integrate `N{U,S}WAddLike` into existing folds
Just went a quick replacement of `N{U,S}WAdd` with the `Like` variant that old matches `or disjoint`
Closes #86082
|
| #
ac13e5c0 |
| 21-Mar-2024 |
Noah Goldstein <goldstein.w.n@gmail.com> |
[InstCombine] Add tests for integrating `N{U,S}WAddLike`; NFC
|
|
Revision tags: llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3 |
|
| #
fd07b8f8 |
| 15-Feb-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][tests/Transforms/InstCombine] Convert instances of ConstantExpr based splats to use splat().
This is mostly NFC but some output does change due to consistently inserting into poison rather th
[LLVM][tests/Transforms/InstCombine] Convert instances of ConstantExpr based splats to use splat().
This is mostly NFC but some output does change due to consistently inserting into poison rather than undef and using i64 as the index type for inserts.
show more ...
|
|
Revision tags: llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init |
|
| #
1c494198 |
| 13-Dec-2023 |
Z572 <zhengjunjie@iscas.ac.cn> |
[InstCombine] simplify `(X * C0) / (X * C1)` into `C0 / C1`. (#73204)
fix #72114
proof: https://alive2.llvm.org/ce/z/xqprFm
|
|
Revision tags: llvmorg-17.0.6 |
|
| #
865c1fda |
| 17-Nov-2023 |
Yingwei Zheng <dtcxzyw2333@gmail.com> |
[InstCombine] Preserve NSW flags for neg instructions (#72548)
Alive2: https://alive2.llvm.org/ce/z/F9HG3M
This missed optimization is discovered with the help of
https://github.com/AliveToolkit
[InstCombine] Preserve NSW flags for neg instructions (#72548)
Alive2: https://alive2.llvm.org/ce/z/F9HG3M
This missed optimization is discovered with the help of
https://github.com/AliveToolkit/alive2/pull/962.
show more ...
|
| #
c350a1ea |
| 15-Nov-2023 |
Z572 <zhengjunjie@iscas.ac.cn> |
[InstCombine] Simplifiy `sdiv -X, X` into `X == INT_MIN ? 1 : -1` (#71768)
Alive2: https://alive2.llvm.org/ce/z/dHddwH
Fixes #69574
|
|
Revision tags: 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 |
|
| #
61d2f3a7 |
| 15-Mar-2023 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Canonicalize icmp eq pow2 more thoroughly
We currently already canonicalize icmp eq (%x & Pow2), Pow2 to icmp ne (%x & Pow2), 0. This patch generalizes the fold based on known bits.
I
[InstCombine] Canonicalize icmp eq pow2 more thoroughly
We currently already canonicalize icmp eq (%x & Pow2), Pow2 to icmp ne (%x & Pow2), 0. This patch generalizes the fold based on known bits.
In particular, this allows us to handle comparisons against !range !{i64 0, i64 2} loads, which addresses an optimization regression in Rust caused by 8df376db7282b955e7990cb8887ee9dcd3565040.
Differential Revision: https://reviews.llvm.org/D146149
show more ...
|
|
Revision tags: llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3 |
|
| #
703423c2 |
| 20-Feb-2023 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] relax constraint on udiv fold
The pair of div folds was just added with: 4966d8ebe1bbe5bd6a4d28
But as noted in the post-commit review, we don't actually need the no-remainder require
[InstCombine] relax constraint on udiv fold
The pair of div folds was just added with: 4966d8ebe1bbe5bd6a4d28
But as noted in the post-commit review, we don't actually need the no-remainder requirement for an unsigned division (still need the no-unsigned-wrap though): https://alive2.llvm.org/ce/z/qHjK3Q
show more ...
|
| #
4966d8eb |
| 20-Feb-2023 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] distribute div over add with matching mul-by-constant
((X * C2) + C1) / C2 --> X + C1/C2 https://alive2.llvm.org/ce/z/P66io8 https://alive2.llvm.org/ce/z/vghegw
This could be made mor
[InstCombine] distribute div over add with matching mul-by-constant
((X * C2) + C1) / C2 --> X + C1/C2 https://alive2.llvm.org/ce/z/P66io8 https://alive2.llvm.org/ce/z/vghegw
This could be made more general -- the multiplier could be a multiple of the divisor -- but this is the pattern from issue #60754.
show more ...
|
| #
f49d19d5 |
| 20-Feb-2023 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] add tests for div with muladd operand; NFC
issue #60754
|
|
Revision tags: llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7 |
|
| #
eae26b66 |
| 04-Jan-2023 |
Paul Walker <paul.walker@arm.com> |
[IRBuilder] Use canonical i64 type for insertelement index used by vector splats.
Instcombine prefers this canonical form (see getPreferredVectorIndex), as does IRBuilder when passing the index as a
[IRBuilder] Use canonical i64 type for insertelement index used by vector splats.
Instcombine prefers this canonical form (see getPreferredVectorIndex), as does IRBuilder when passing the index as an integer so we may as well use the prefered form from creation.
NOTE: All test changes are mechanical with nothing else expected beyond a change of index type from i32 to i64.
Differential Revision: https://reviews.llvm.org/D140983
show more ...
|
|
Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3 |
|
| #
7ec604a3 |
| 11-Oct-2022 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] try harder to cancel out mul/div
((Op1 * X) / Y) / Op1 --> X / Y https://alive2.llvm.org/ce/z/JYxWjA
InstSimplify handles the more basic mul+div pattern with shared operand, but we do
[InstCombine] try harder to cancel out mul/div
((Op1 * X) / Y) / Op1 --> X / Y https://alive2.llvm.org/ce/z/JYxWjA
InstSimplify handles the more basic mul+div pattern with shared operand, but we don't seem to have any reassociation folds to handle cases where the common op is further away.
This is a generalization of 9cff4711ac72 and another transform derived from issue #58137.
show more ...
|
| #
5185c5db |
| 11-Oct-2022 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] add tests for div with common mul operand; NFC
|
|
Revision tags: working, llvmorg-15.0.2 |
|
| #
4ab40eca |
| 03-Oct-2022 |
Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> |
[test][InstCombine] Update some test cases to use opaque pointers
These tests cases were converted using the script at https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34
Differential Re
[test][InstCombine] Update some test cases to use opaque pointers
These tests cases were converted using the script at https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34
Differential Revision: https://reviews.llvm.org/D135094
show more ...
|
|
Revision tags: 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 |
|
| #
952e0693 |
| 10-Jun-2022 |
Nuno Lopes <nuno.lopes@tecnico.ulisboa.pt> |
[NFC] remove 'br undef' from InstCombine test cases This is UB and allows the compiler to give any result, so these tests weren't meaningful InstCombine tests are now clean of 'br undef'
|
|
Revision tags: llvmorg-14.0.4 |
|
| #
99ef341c |
| 11-May-2022 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] freeze operand in sdiv expansion
As discussed in issue #37809, this transform is not safe if the input is an undefined value.
This is similar to a recent change for urem: d428f09b2c9d
[InstCombine] freeze operand in sdiv expansion
As discussed in issue #37809, this transform is not safe if the input is an undefined value.
This is similar to a recent change for urem: d428f09b2c9d
There is no difference in codegen on the basic examples, but this could lead to regressions. We may need to improve freeze analysis or lowering if that happens.
Presumably, in real cases that are similar to the tests where a subsequent transform removes the select, we will also be able to remove the freeze by seeing that the parameter has 'noundef'.
show more ...
|
| #
5fdfcf48 |
| 11-May-2022 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] update auto-generated CHECK lines in test file; NFC
These are all cosmetic (value naming) diffs that would distract from real changes in this file.
|
|
Revision tags: llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1 |
|
| #
467cbb62 |
| 08-Apr-2022 |
Chenbing Zheng <Chenbing.Zheng@streamcomputing.com> |
[InstCombine] fold more constant divisor to select-of-constants divisor
By adding a parameter to function FoldOpIntoSelect, we can fold more Ops to Select. For this example, we tend to fold the divi
[InstCombine] fold more constant divisor to select-of-constants divisor
By adding a parameter to function FoldOpIntoSelect, we can fold more Ops to Select. For this example, we tend to fold the division instruction, so we no longer care whether SelectInst is one use.
This patch slove TODO left in InstCombine/div.ll.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D122967
show more ...
|
|
Revision tags: llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1 |
|
| #
acdc419c |
| 04-Feb-2022 |
Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> |
[test] Use -passes=instcombine instead of -instcombine in lots of tests. NFC
Another step moving away from the deprecated syntax of specifying pass pipeline in opt.
Differential Revision: https://r
[test] Use -passes=instcombine instead of -instcombine in lots of tests. NFC
Another step moving away from the deprecated syntax of specifying pass pipeline in opt.
Differential Revision: https://reviews.llvm.org/D119081
show more ...
|
| #
4f97aa7e |
| 05-Feb-2022 |
Simon Pilgrim <llvm-dev@redking.me.uk> |
[InstCombine] Add PR34063 test coverage
|