Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6 |
|
#
02328e04 |
| 16-Dec-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][ConstantFold] Remove remaining uses of ConstantInt/FP::get(LLVMContext... (#119912)
This extends the constant folds to support vector ConstantInt/FP.
|
Revision tags: llvmorg-19.1.5 |
|
#
af641ff2 |
| 21-Nov-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][IR] Refactor ConstantFold:FoldBitCast to fully support vector ConstantInt/FP. (#116787)
This fixes the code quality issue reported in
https://github.com/llvm/llvm-project/pull/111149.
|
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 ...
|
#
6f10b652 |
| 02-Nov-2024 |
Kazu Hirata <kazu@google.com> |
[IR] Remove unused includes (NFC) (#114679)
Identified with misc-include-cleaner.
|
#
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 |
|
#
14db0694 |
| 25-Oct-2024 |
ssijaric-nv <ssijaric@nvidia.com> |
[InstCombine] Fix a cycle when folding fneg(select) with scalable vector types (#112465)
The two folding operations are causing a cycle for the following case
with
scalable vector types:
define
[InstCombine] Fix a cycle when folding fneg(select) with scalable vector types (#112465)
The two folding operations are causing a cycle for the following case
with
scalable vector types:
define <vscale x 2 x double> @test_fneg_select_abs(<vscale x 2 x i1>
%cond, <vscale x 2 x double> %b) {
%1 = select <vscale x 2 x i1> %cond, <vscale x 2 x double>
zeroinitializer, <vscale x 2 x double> %b
%2 = fneg fast <vscale x 2 x double> %1
ret <vscale x 2 x double> %2
}
1) fold fneg: -(Cond ? C : Y) -> Cond ? -C : -Y
2) fold select: (Cond ? -X : -Y) -> -(Cond ? X : Y)
1) results in the following since '<vscale x 2 x double>
zeroinitializer' passes
the check for the immediate constant:
%.neg = fneg fast <vscale x 2 x double> zeroinitializer
%b.neg = fneg fast <vscale x 2 x double> %b
%1 = select fast <vscale x 2 x i1> %cond, <vscale x 2 x double> %.neg,
<vscale x 2 x double> %b.neg
and so we end up going back and forth between 1) and 2).
Attempt to fold scalable vector constants, so that we end up with a
splat instead:
define <vscale x 2 x double> @test_fneg_select_abs(<vscale x 2 x i1>
%cond, <vscale x 2 x double> %b) {
%b.neg = fneg fast <vscale x 2 x double> %b
%1 = select fast <vscale x 2 x i1> %cond, <vscale x 2 x double>
shufflevector (<vscale x 2 x double> insertelement (<vscale x 2 x
double> poison, double -0.000000e+00, i64 0), <vscale x 2 x double>
poison, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x double>
%b.neg
ret <vscale x 2 x double> %1
}
show more ...
|
Revision tags: llvmorg-19.1.2 |
|
#
87cdc832 |
| 08-Oct-2024 |
Paul Walker <paul.walker@arm.com> |
[LLVM][ConstFolds] Verify a scalar src before attempting scalar->vector bitcast transformation. (#111149)
It was previously safe to assume isa<Constant{Int,FP}> meant a scalar
value. This is not tr
[LLVM][ConstFolds] Verify a scalar src before attempting scalar->vector bitcast transformation. (#111149)
It was previously safe to assume isa<Constant{Int,FP}> meant a scalar
value. This is not true when use-constant-##-for-###-splat are enabled.
show more ...
|
#
a59e5d81 |
| 01-Oct-2024 |
eric-xtang1008 <eric.tang@starfivetech.com> |
[ConstantFold][RFC] Add AllowLHSConstant parameter in getBinOpAbsorber (#109736)
Add a AllowLHSConstant parameter in getBinOpAbsorber function for
supporting more binary operators.
|
Revision tags: 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 |
|
#
dfeb3991 |
| 25-Jul-2024 |
James Y Knight <jyknight@google.com> |
Remove the `x86_mmx` IR type. (#98505)
It is now translated to `<1 x i64>`, which allows the removal of a bunch
of special casing.
This _incompatibly_ changes the ABI of any LLVM IR function wit
Remove the `x86_mmx` IR type. (#98505)
It is now translated to `<1 x i64>`, which allows the removal of a bunch
of special casing.
This _incompatibly_ changes the ABI of any LLVM IR function with
`x86_mmx` arguments or returns: instead of passing in mmx registers,
they will now be passed via integer registers. However, the real-world
incompatibility caused by this is expected to be minimal, because Clang
never uses the x86_mmx type -- it lowers `__m64` to either `<1 x i64>`
or `double`, depending on ABI.
This change does _not_ eliminate the SelectionDAG `MVT::x86mmx` type.
That type simply no longer corresponds to an IR type, and is used only
by MMX intrinsics and inline-asm operands.
Because SelectionDAGBuilder only knows how to generate the
operands/results of intrinsics based on the IR type, it thus now
generates the intrinsics with the type MVT::v1i64, instead of
MVT::x86mmx. We need to fix this before the DAG LegalizeTypes, and thus
have the X86 backend fix them up in DAGCombine. (This may be a
short-lived hack, if all the MMX intrinsics can be removed in upcoming
changes.)
Works towards issue #98272.
show more ...
|
Revision tags: llvmorg-20-init |
|
#
76d3ab2c |
| 20-Jun-2024 |
Nikita Popov <npopov@redhat.com> |
[IR] Remove support for shl constant expressions (#96037)
Remove support for shl constant expressions, as part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
|
Revision tags: llvmorg-18.1.8 |
|
#
cc2dc091 |
| 12-Jun-2024 |
Nikita Popov <npopov@redhat.com> |
Reapply [ConstantFold] Drop gep of gep fold entirely (#95126)
Reapplying without changes. The flang+openmp buildbot failure should be addressed by https://github.com/llvm/llvm-project/pull/94541.
-
Reapply [ConstantFold] Drop gep of gep fold entirely (#95126)
Reapplying without changes. The flang+openmp buildbot failure should be addressed by https://github.com/llvm/llvm-project/pull/94541.
-----
This is a followup to https://github.com/llvm/llvm-project/pull/93823 and drops the DataLayout-unaware GEP of GEP fold entirely. All cases are now left to the DataLayout-aware constant folder, which will fold everything to a single i8 GEP.
We didn't have any test coverage for this fold in LLVM, but some Clang tests change.
show more ...
|
#
cece0a10 |
| 12-Jun-2024 |
Nikita Popov <npopov@redhat.com> |
Revert "[ConstantFold] Drop gep of gep fold entirely (#95126)"
This reverts commit 3b3b839c66dc49674fd6646650525a2173030690.
This broke the flang+openmp+offload buildbot, as reported in https://git
Revert "[ConstantFold] Drop gep of gep fold entirely (#95126)"
This reverts commit 3b3b839c66dc49674fd6646650525a2173030690.
This broke the flang+openmp+offload buildbot, as reported in https://github.com/llvm/llvm-project/pull/95126#issuecomment-2162424019.
show more ...
|
#
3b3b839c |
| 12-Jun-2024 |
Nikita Popov <npopov@redhat.com> |
[ConstantFold] Drop gep of gep fold entirely (#95126)
This is a followup to https://github.com/llvm/llvm-project/pull/93823
and drops the DataLayout-unaware GEP of GEP fold entirely. All cases are
[ConstantFold] Drop gep of gep fold entirely (#95126)
This is a followup to https://github.com/llvm/llvm-project/pull/93823
and drops the DataLayout-unaware GEP of GEP fold entirely. All cases are
now left to the DataLayout-aware constant folder, which will fold
everything to a single i8 GEP.
We didn't have any test coverage for this fold in LLVM, but some Clang
tests change.
show more ...
|
Revision tags: llvmorg-18.1.7 |
|
#
cc158d4c |
| 31-May-2024 |
Nikita Popov <npopov@redhat.com> |
Reapply [ConstantFold] Remove non-trivial gep-of-gep fold (#93823)
Reapply after https://github.com/llvm/llvm-project/pull/93956, which changed clang array initialization codegen to avoid size regre
Reapply [ConstantFold] Remove non-trivial gep-of-gep fold (#93823)
Reapply after https://github.com/llvm/llvm-project/pull/93956, which changed clang array initialization codegen to avoid size regressions for unoptimized builds.
-----
This fold is subtly incorrect, because DL-unaware constant folding does not know the correct index type to use, and just performs the addition in the type that happens to already be there. This is incorrect, since sext(X)+sext(Y) is generally not the same as sext(X+Y). See the `@constexpr_gep_of_gep_with_narrow_type()` for a miscompile with the current implementation.
One could try to restrict the fold to cases where no overflow occurs, but I'm not bothering with that here, because the DL-aware constant folding will take care of this anyway. I've only kept the straightforward zero-index case, where we just concatenate two GEPs.
show more ...
|
#
deab451e |
| 04-Jun-2024 |
Nikita Popov <npopov@redhat.com> |
[IR] Remove support for icmp and fcmp constant expressions (#93038)
Remove support for the icmp and fcmp constant expressions.
This is part of:
https://discourse.llvm.org/t/rfc-remove-most-const
[IR] Remove support for icmp and fcmp constant expressions (#93038)
Remove support for the icmp and fcmp constant expressions.
This is part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
As usual, many of the updated tests will no longer test what they were
originally intended to -- this is hard to preserve when constant
expressions get removed, and in many cases just impossible as the
existence of a specific kind of constant expression was the cause of the
issue in the first place.
show more ...
|
#
51e459a5 |
| 31-May-2024 |
Nikita Popov <npopov@redhat.com> |
Revert "[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)"
This reverts commit e1cc9e4eaddcc295b4e775512e33b947b1514c17.
This causes some non-trivial text size increases in unoptimized bui
Revert "[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)"
This reverts commit e1cc9e4eaddcc295b4e775512e33b947b1514c17.
This causes some non-trivial text size increases in unoptimized builds for Bullet. Revert while I investigate.
show more ...
|
#
e1cc9e4e |
| 31-May-2024 |
Nikita Popov <npopov@redhat.com> |
[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)
This fold is subtly incorrect, because DL-unaware constant folding does
not know the correct index type to use, and just performs the addi
[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)
This fold is subtly incorrect, because DL-unaware constant folding does
not know the correct index type to use, and just performs the addition
in the type that happens to already be there. This is incorrect, since
sext(X)+sext(Y) is generally not the same as sext(X+Y). See the
`@constexpr_gep_of_gep_with_narrow_type()` for a miscompile with the
current implementation.
One could try to restrict the fold to cases where no overflow occurs,
but I'm not bothering with that here, because the DL-aware constant
folding will take care of this anyway. I've only kept the
straightforward zero-index case, where we just concatenate two GEPs.
show more ...
|
#
63dc31b6 |
| 22-May-2024 |
Nikita Popov <npopov@redhat.com> |
Reapply [IR] Avoid creating icmp/fcmp constant expressions (#92885)
Reapply after https://github.com/llvm/llvm-project/pull/93548, which should address the lldb failure on macos.
-----
Do not crea
Reapply [IR] Avoid creating icmp/fcmp constant expressions (#92885)
Reapply after https://github.com/llvm/llvm-project/pull/93548, which should address the lldb failure on macos.
-----
Do not create icmp/fcmp constant expressions in IRBuilder etc anymore, i.e. treat them as "undesirable". This is in preparation for removing them entirely.
Part of: https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
show more ...
|
#
d10b7655 |
| 30-May-2024 |
Nikita Popov <npopov@redhat.com> |
[ConstantFold] Remove notional over-indexing fold (#93697)
The data-layout independent constant folding currently has some rather
gnarly code for canonicalizing GEP indices to reduce "notional
ove
[ConstantFold] Remove notional over-indexing fold (#93697)
The data-layout independent constant folding currently has some rather
gnarly code for canonicalizing GEP indices to reduce "notional
overindexing", and then infers inbounds based on that canonicalization.
Now that we canonicalize to i8 GEPs, this canonicalization is
essentially useless, as we'll discard it as soon as the GEP hits the
data-layout aware constant folder anyway. As such, I'd like to remove
this code entirely.
This shouldn't have any impact on optimization capabilities.
show more ...
|
#
1383cb6e |
| 28-May-2024 |
Nikita Popov <npopov@redhat.com> |
[ConstFold] Fix incorrect gep inbounds of undef fold
gep inbounds of undef can only be folded to poison if we know that the offset is non-zero. I don't think precise handling here is important, so j
[ConstFold] Fix incorrect gep inbounds of undef fold
gep inbounds of undef can only be folded to poison if we know that the offset is non-zero. I don't think precise handling here is important, so just drop the inbounds special case. This matches what InstSimplify does.
show more ...
|
#
8cdecd4d |
| 27-May-2024 |
Nikita Popov <npopov@redhat.com> |
[IR] Add getelementptr nusw and nuw flags (#90824)
This implements the `nusw` and `nuw` flags for `getelementptr` as
proposed at
https://discourse.llvm.org/t/rfc-add-nusw-and-nuw-flags-for-getelem
[IR] Add getelementptr nusw and nuw flags (#90824)
This implements the `nusw` and `nuw` flags for `getelementptr` as
proposed at
https://discourse.llvm.org/t/rfc-add-nusw-and-nuw-flags-for-getelementptr/78672.
The three possible flags are encapsulated in the new `GEPNoWrapFlags`
class. Currently this class has a ctor from bool, interpreted as the
InBounds flag. This ctor should be removed in the future, as code gets
migrated to handle all flags.
There are a few places annotated with `TODO(gep_nowrap)`, where I've had
to touch code but opted to not infer or precisely preserve the new
flags, so as to keep this as NFC as possible and make sure any changes
of that kind get test coverage when they are made.
show more ...
|
#
8baf96f3 |
| 22-May-2024 |
Daniel Thornburgh <dthorn@google.com> |
Revert "[IR] Avoid creating icmp/fcmp constant expressions" (#93087)
Reverts llvm/llvm-project#92885 due to LLDB CI breakages.
|
#
108575f0 |
| 22-May-2024 |
Nikita Popov <npopov@redhat.com> |
[IR] Avoid creating icmp/fcmp constant expressions (#92885)
Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for remov
[IR] Avoid creating icmp/fcmp constant expressions (#92885)
Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for removing
them entirely.
Part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
show more ...
|
Revision tags: llvmorg-18.1.6 |
|
#
37c6b9ff |
| 14-May-2024 |
Paul Walker <paul.walker@arm.com> |
[NFC][LLVM] Mainly whitespace changes.
Also marks AliasSetTracker::size() as const.
|
Revision tags: llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3 |
|
#
0f46e31c |
| 20-Mar-2024 |
Nikita Popov <npopov@redhat.com> |
[IR] Change representation of getelementptr inrange (#84341)
As part of the migration to ptradd
(https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699),
we need to change the
[IR] Change representation of getelementptr inrange (#84341)
As part of the migration to ptradd
(https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699),
we need to change the representation of the `inrange` attribute, which
is used for vtable splitting.
Currently, inrange is specified as follows:
```
getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @vt, i64 0, inrange i32 1, i64 2)
```
The `inrange` is placed on a GEP index, and all accesses must be "in
range" of that index. The new representation is as follows:
```
getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [4 x ptr] }, ptr @vt, i64 0, i32 1, i64 2)
```
This specifies which offsets are "in range" of the GEP result. The new
representation will continue working when canonicalizing to ptradd
representation:
```
getelementptr inbounds inrange(-16, 16) (i8, ptr @vt, i64 48)
```
The inrange offsets are relative to the return value of the GEP. An
alternative design could make them relative to the source pointer
instead. The result-relative format was chosen on the off-chance that we
want to extend support to non-constant GEPs in the future, in which case
this variant is more expressive.
This implementation "upgrades" the old inrange representation in bitcode
by simply dropping it. This is a very niche feature, and I don't think
trying to upgrade it is worthwhile. Let me know if you disagree.
show more ...
|