Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5 |
|
#
4872ecf1 |
| 21-Nov-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][IR] Teach extractelement folds about constant ConstantInt/FP. (#116793)
|
#
a3f2e01c |
| 20-Nov-2024 |
peterbell10 <peterbell10@openai.com> |
[InstCombine] Only fold extract element to trunc if vector `hasOneUse` (#115627)
This fixes a missed optimization caused by the `foldBitcastExtElt`
pattern interfering with other combine patterns.
[InstCombine] Only fold extract element to trunc if vector `hasOneUse` (#115627)
This fixes a missed optimization caused by the `foldBitcastExtElt`
pattern interfering with other combine patterns. In the case I was
hitting, we have IR that combines two vectors into a new larger vector
by extracting elements and inserting them into the new vector.
```llvm
define <4 x half> @bitcast_extract_insert_to_shuffle(i32 %a, i32 %b) {
%avec = bitcast i32 %a to <2 x half>
%a0 = extractelement <2 x half> %avec, i32 0
%a1 = extractelement <2 x half> %avec, i32 1
%bvec = bitcast i32 %b to <2 x half>
%b0 = extractelement <2 x half> %bvec, i32 0
%b1 = extractelement <2 x half> %bvec, i32 1
%ins0 = insertelement <4 x half> undef, half %a0, i32 0
%ins1 = insertelement <4 x half> %ins0, half %a1, i32 1
%ins2 = insertelement <4 x half> %ins1, half %b0, i32 2
%ins3 = insertelement <4 x half> %ins2, half %b1, i32 3
ret <4 x half> %ins3
}
```
With the current behavior, `InstCombine` converts each vector extract
sequence to
```llvm
%tmp = trunc i32 %a to i16
%a0 = bitcast i16 %tmp to half
%a1 = extractelement <2 x half> %avec, i32 1
```
where the extraction of `%a0` is now done by truncating the original
integer. While on it's own this is fairly reasonable, in this case it
also blocks the pattern which converts `extractelement` -
`insertelement` into shuffles which gives the overall simpler result:
```llvm
define <4 x half> @bitcast_extract_insert_to_shuffle(i32 %a, i32 %b) {
%avec = bitcast i32 %a to <2 x half>
%bvec = bitcast i32 %b to <2 x half>
%ins3 = shufflevector <2 x half> %avec, <2 x half> %bvec, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
ret <4 x half> %ins3
}
```
In this PR I fix the conflict by obeying the `hasOneUse` check even if
there is no shift instruction required. In these cases we can't remove
the vector completely, so the pattern has less benefit anyway.
Also fwiw, I think dropping the `hasOneUse` check for the 0th element
might have been a mistake in the first place. Looking at
https://github.com/llvm/llvm-project/commit/535c5d56a7bc9966036a11362d8984983a4bf090
the commit message only mentions loosening the `isDesirableIntType`
requirement and doesn't mention changing the `hasOneUse` check at all.
show more ...
|
Revision tags: llvmorg-19.1.4, llvmorg-19.1.3, 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 |
|
#
b1094776 |
| 11-Apr-2024 |
Yingwei Zheng <dtcxzyw2333@gmail.com> |
[InstCombine] Infer nsw/nuw for trunc (#87910)
This patch adds support for inferring trunc's nsw/nuw flags.
|
Revision tags: 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 |
|
#
9d455792 |
| 18-Dec-2023 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Don't treat undef as poison in demanded element simplification
We can only set PoisonElts if the element is poison, not if it is undef.
|
#
e400c59b |
| 18-Dec-2023 |
Nikita Popov <npopov@redhat.com> |
Revert "[InstCombine] Favour `m_Poison` in `SimplifyDemandedVectorElts`"
This reverts commit 318d5bff0b65aa7d52fc7004d49587416f0fb564.
Has incomplete test updates.
|
#
318d5bff |
| 18-Dec-2023 |
Antonio Frighetto <me@antoniofrighetto.com> |
[InstCombine] Favour `m_Poison` in `SimplifyDemandedVectorElts`
A miscompilation issue has been addressed with refined checking.
|
#
a5f34155 |
| 18-Dec-2023 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Replace non-demanded undef vector with poison
If an operand (esp to shufflevector or insertelement) is not demanded, canonicalize it from undef to poison.
|
Revision tags: llvmorg-17.0.6 |
|
#
be32e398 |
| 17-Nov-2023 |
Yingwei Zheng <dtcxzyw2333@gmail.com> |
[ValueTracking] Ignore poison values in `computeKnownBits` (#72683)
This patch handles `poison` elements of non-splat vectors in
`computeKnownBits`. It addresses test changes after I delete the
du
[ValueTracking] Ignore poison values in `computeKnownBits` (#72683)
This patch handles `poison` elements of non-splat vectors in
`computeKnownBits`. It addresses test changes after I delete the
duplicate logic in https://github.com/llvm/llvm-project/pull/72535.
See also @nikic's comment:
https://github.com/llvm/llvm-project/pull/72535#pullrequestreview-1736991557
show more ...
|
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 |
|
#
ab94c1ba |
| 23-Jun-2023 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Add created extracts to worklist
Use InstCombine's insertion helper for the created extracts, so they become part of the worklist and will be revisited.
|
Revision tags: llvmorg-16.0.6, llvmorg-16.0.5 |
|
#
3a223f1e |
| 24-May-2023 |
Nikita Popov <npopov@redhat.com> |
[InstCombine] Fix crash due to early extractvalue removal
Fixes the issue reported at https://github.com/llvm/llvm-project/commit/4b8320868c9e32d1448c81ca76dba2a6b9f374cd#commitcomment-114671248.
T
[InstCombine] Fix crash due to early extractvalue removal
Fixes the issue reported at https://github.com/llvm/llvm-project/commit/4b8320868c9e32d1448c81ca76dba2a6b9f374cd#commitcomment-114671248.
The extractvalue instructions may still be used by the calling code in some cases. Rather than trying to figure out which extracts are safe to remove and which aren't, add them to the worklist so they will get DCEd by the main loop.
show more ...
|
Revision tags: llvmorg-16.0.4, llvmorg-16.0.3 |
|
#
8b56da5e |
| 26-Apr-2023 |
ManuelJBrito <manuel.brito@tecnico.ulisboa.pt> |
[IR] Change shufflevector undef mask to poison
With this patch an undefined mask in a shufflevector will be printed as poison. This change is done to support the new shufflevector semantics for unde
[IR] Change shufflevector undef mask to poison
With this patch an undefined mask in a shufflevector will be printed as poison. This change is done to support the new shufflevector semantics for undefined mask elements.
Differential Revision: https://reviews.llvm.org/D149210
show more ...
|
Revision tags: 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, llvmorg-15.0.6 |
|
#
535c5d56 |
| 24-Nov-2022 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] ease restriction for extractelt (bitcast X) fold
We were checking for a desirable integer type even when there is no shift in the transform. This is unnecessary since we are truncating
[InstCombine] ease restriction for extractelt (bitcast X) fold
We were checking for a desirable integer type even when there is no shift in the transform. This is unnecessary since we are truncating directly to the destination type.
This removes an extractelt in more cases and seems to make the canonicalization more uniform overall. There's still a potential difference between patterns that need a shift vs. trunc-only.
I'm not sure if that is worth keeping at this point, but it can be adjusted in another step (assuming this change does not cause trouble).
In the most basic case where I noticed this, we missed a fold that would have completely removed vector ops from a pattern like: https://alive2.llvm.org/ce/z/y4Qdte
show more ...
|
Revision tags: llvmorg-15.0.5 |
|
#
470aea5e |
| 14-Nov-2022 |
Thomas Symalla <github@thomassymalla.de> |
[InstCombine] Fold extractelt with select of constants
An extractelt with a constant index which extracts an element from the two vector operands of a select can be directly folded into a select.
e
[InstCombine] Fold extractelt with select of constants
An extractelt with a constant index which extracts an element from the two vector operands of a select can be directly folded into a select.
extractelt (select %x, %vec1, %vec2), %const -> select %x, %vec1[%const], %vec2[%const]
Note: the implementation currently only works for constant vector operands.
Reviewed By: foad, spatel
Differential Revision: https://reviews.llvm.org/D137934
show more ...
|
#
9ab2969e |
| 21-Nov-2022 |
Thomas Symalla <thomas.symalla@amd.com> |
[NFC][InstCombine] Pre-commit tests for D137934
Various InstCombine tests to show diffs with the new extractelement / select folding.
|
#
034df6f7 |
| 14-Nov-2022 |
Thomas Symalla <thomas.symalla@amd.com> |
[InstCombine][NFC] Add extractelement tests
|
Revision tags: llvmorg-15.0.4, llvmorg-15.0.3, 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 |
|
#
df525c77 |
| 26-Aug-2022 |
jacquesguan <Jianjian.Guan@streamcomputing.com> |
[InstCombine] fold fake floating point vector extract to shift+trunc.
This patch supports the FP part of D111082.
Differential Revision: https://reviews.llvm.org/D125750
|
#
f98153ea |
| 26-Aug-2022 |
jacquesguan <Jianjian.Guan@streamcomputing.com> |
[InstCombine] Precommit test for D125750.
Differential Revision: https://reviews.llvm.org/D126054
|
Revision tags: 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, llvmorg-14.0.1, 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 ...
|
Revision tags: llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2 |
|
#
e6ad9ef4 |
| 14-Dec-2021 |
Philip Reames <listmail@philipreames.com> |
[instcombine] Canonicalize constant index type to i64 for extractelement/insertelement
The basic idea to this is that a) having a single canonical type makes CSE easier, and b) many of our transform
[instcombine] Canonicalize constant index type to i64 for extractelement/insertelement
The basic idea to this is that a) having a single canonical type makes CSE easier, and b) many of our transforms are inconsistent about which types we end up with based on visit order.
I'm restricting this to constants as for non-constants, we'd have to decide whether the simplicity was worth extra instructions. For constants, there are no extra instructions.
We chose the canonical type as i64 arbitrarily. We might consider changing this to something else in the future if we have cause.
Differential Revision: https://reviews.llvm.org/D115387
show more ...
|
Revision tags: llvmorg-13.0.1-rc1 |
|
#
d95ebef4 |
| 07-Oct-2021 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] ease use check for fold of bitcasted extractelt to trunc
This helps with examples like: https://llvm.org/PR52057 ...but we need at least one more fold to fix that case.
|
#
db231ebd |
| 06-Oct-2021 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] fold fake vector extract to shift+trunc
We already handle more complicated cases like: extelt (bitcast (inselt poison, X, 0)) --> trunc (lshr X)
But we missed this simpler pattern: ht
[InstCombine] fold fake vector extract to shift+trunc
We already handle more complicated cases like: extelt (bitcast (inselt poison, X, 0)) --> trunc (lshr X)
But we missed this simpler pattern: https://alive2.llvm.org/ce/z/D55h64 / https://alive2.llvm.org/ce/z/GKzzRq
This is part of solving: https://llvm.org/PR52057
I made the transform depend on legal/desirable int type to avoid creating a shift of an illegal type (for example i128). I'm not sure if that restriction is actually necessary, but we can change that as a follow-up if the backend can deal with integer ops on too-wide illegal types.
The pile of AVX512 test changes are all neutral AFAICT - the x86 backend seems to know how to turn that into the expected "kmov" instructions.
Differential Revision: https://reviews.llvm.org/D111082
show more ...
|
#
bd2c6e52 |
| 04-Oct-2021 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] add tests for extractelt of bitcasted scalar; NFC
|
Revision tags: llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2 |
|
#
7161bb87 |
| 31-May-2021 |
Juneyoung Lee <aqjune@gmail.com> |
[InsCombine] Fix a few remaining vec transforms to use poison instead of undef
This is a patch that replaces shufflevector and insertelement's placeholder value with poison.
Underlying motivation i
[InsCombine] Fix a few remaining vec transforms to use poison instead of undef
This is a patch that replaces shufflevector and insertelement's placeholder value with poison.
Underlying motivation is to fix the semantics of shufflevector with undef mask to return poison instead (D93818) The consensus has been made in the late 2020 via mailing list as well as the thread in https://bugs.llvm.org/show_bug.cgi?id=44185 .
This patch is a simple syntactic change to the existing code, hence directly pushed as a commit.
show more ...
|
Revision tags: llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4, llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1 |
|
#
3a60a1f1 |
| 03-Jan-2021 |
Juneyoung Lee <aqjune@gmail.com> |
[InstSimplify] Fold insertelement vec, poison, idx into vec
This is a simple patch that adds folding from `insertelement vec, poison, idx` into `vec`.
Alive2 proof: https://alive2.llvm.org/ce/z/2y2
[InstSimplify] Fold insertelement vec, poison, idx into vec
This is a simple patch that adds folding from `insertelement vec, poison, idx` into `vec`.
Alive2 proof: https://alive2.llvm.org/ce/z/2y2vbC
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D93994
show more ...
|