7340 Commits

Author SHA1 Message Date
Roman Lebedev
5fb9e84047
[NFC] Port all InstCombine tests to -passes= syntax 2022-12-08 02:38:44 +03:00
Alex Richardson
9114ac67a9 Overload all llvm.annotation intrinsics for globals argument
The global constant arguments could be in a different address space
than the first argument, so we have to add another overloaded argument.
This patch was originally made for CHERI LLVM (where globals can be in
address space 200), but it also appears to be useful for in-tree targets
as can be seen from the test diffs.

Differential Revision: https://reviews.llvm.org/D138722
2022-12-07 18:29:18 +00:00
chenglin.bi
b4c8cfc7c2 [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
2022-12-07 23:55:49 +08:00
chenglin.bi
10c3df728c [Instcombine] Canonicalize ~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
https://alive2.llvm.org/ce/z/JHN2p4

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D139299
2022-12-07 23:52:07 +08:00
Chenbing Zheng
463e9be1d4 [InstCombine] Add tests for (X << Z) / (X * Y) -> (1 << Z) / Y. nfc 2022-12-07 17:06:11 +08:00
Sanjay Patel
71df24dd39 [InstCombine] fold add-carry of bools to logic
((zext BoolX) + (zext BoolY)) >> 1 --> zext (BoolX && BoolY)
https://alive2.llvm.org/ce/z/LvZFKj

This was noted as a missing fold in D138814.
2022-12-06 13:42:42 -05:00
Sanjay Patel
924233c784 [InstCombine] add tests for bool math; NFC
This pattern came up in D138814.
2022-12-06 13:42:42 -05:00
Matt Arsenault
e2f56debb3 InstCombine: Fold fabs (copysign x, y) -> fabs x 2022-12-06 08:29:14 -05:00
Matt Arsenault
84a8a57a86 InstCombine: Add baseline tests for copysign with fneg/fabs 2022-12-06 08:29:14 -05:00
chenglin.bi
3e4ae76d03 [Instcombine] Add baseline tests for logic-and/logic-or factorization; NFC 2022-12-06 17:35:35 +08:00
Simon Pilgrim
f2bfe0f84a [InstCombine] Regenerate select-gep.ll test checks
Fixes superfluous diffs identified in D139253
2022-12-05 21:19:43 +00:00
Simon Pilgrim
f9faf832a6 [InstCombine] Regenerate select-bitext.ll test checks
Fixes superfluous diffs identified in D139253
2022-12-05 21:19:43 +00:00
Simon Pilgrim
531ef2cd24 [InstCombine] Regenerate select-cmpxchg.ll test checks 2022-12-05 21:19:42 +00:00
Simon Pilgrim
6f12fc2b82 [InstCombine] Regenerate select-masked_load.ll test checks 2022-12-05 21:19:42 +00:00
Simon Pilgrim
8c42da536c [InstCombine] Regenerate opaque-ptr.ll test checks
Fixes superfluous diffs identified in D139253
2022-12-05 21:19:42 +00:00
Paul Walker
03b3017aef [InstCombine] Increase test coverage of vector.reverse ready for follow on work. 2022-12-05 17:03:00 +00:00
chenglin.bi
683e03d6d8 [Instcombine] Precommit tests for some or canonicalization; NFC
~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
~(A & B) ^ (A | ?) -> (A & B) | ~(A | ?)
2022-12-06 00:32:10 +08:00
chenglin.bi
18cae673a4 [Instcombine] Precommit tests for D139080; NFC
Test pattern for
(C & X) | ~(C | Y) -> C ? X : ~Y
2022-12-06 00:23:28 +08:00
chenglin.bi
b966fb08a2 [InstCombine] Precommit tests for D139253; NFC 2022-12-06 00:00:54 +08:00
Matt Arsenault
51af4ddfc2 ValueTracking: Teach canCreateUndefOrPoison about more intrinsics
I tried to test the fallthrough to noundef callsite return attribute
case, but it seems that folds out as-is.
2022-12-05 10:04:13 -05:00
Matt Arsenault
dfa842e45a ValueTracking: Add some baseline intrinsic with freeze tests 2022-12-05 09:40:58 -05:00
Roman Lebedev
b79921a4a8
[NFC] Re-autogenerate checklines in a few tests being affected 2022-12-04 20:58:55 +03:00
chenglin.bi
e719550e6f [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
2022-12-03 07:56:19 +08:00
chenglin.bi
6a70b846a4 [InstCombine] Precommit tests for D139076; NFC 2022-12-03 02:01:57 +08:00
Matt Arsenault
997d7d1931 InstCombine: Convert some tests to opaque pointers
Needed manual fixes:
  2008-01-06-VoidCast.ll
  alias.ll @0 type lost
  pr27703.ll totally confused
  pr44242.ll phi and update_test_checks
  pr44245.ll phi and update_test_checks

Needed re-running update_test_checks:
  2009-01-08-AlignAlloca.ll
  2009-02-20-InstCombine-SROA.ll
  addrspacecast.ll
  alloca-cast-debuginfo.ll
  alloca-in-non-alloca-as.ll
  alloca.ll
  icmp-gep.ll
  icmp-custom-dl.ll
  lifetime-no-null-opt.ll
  non-integral-pointers.ll
  pr33689_same_bitwidth.ll
  pr39908.ll
  scalable-cast-of-alloc.ll
  select-cmp-br.ll
  unpack-fca.ll

Converted to generated checks:
  2012-6-7-vselect-bitcast.ll
2022-12-01 23:08:57 -05:00
Matt Arsenault
8be07f6ad6 InstCombine: Don't use anonymous values in tests
These interfered with opaquification
2022-12-01 23:08:57 -05:00
Matt Arsenault
4df6f3f8a3 InstCombine: Stop using grep in some tests
Switch to FileCheck and generated checks.
2022-12-01 23:08:57 -05:00
Matt Arsenault
8fcf387202 InstCombine: Convert target tests to opaque pointers
The opaquify script deleted a few declarations for some reason which
were manually deleted.
2022-12-01 21:56:14 -05:00
Matt Arsenault
ed1ada7521 InstCombine: Don't use anonymous values in test
Also don't use grep because it's not 2002.
2022-12-01 21:55:06 -05:00
Sanjay Patel
dd8d0d21ce [InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 2
This enhances the base fold from part 1 to allow mapping a
right-shift to an insert index.

Example of translating a middle chunk of the scalar to vector
for either endian:
https://alive2.llvm.org/ce/z/fRXCOZ

This only allows creating an identity shuffle (with optional
shortening/lengthening) because that is considered the safe
baseline for any target (can be inverted if needed). If we
tried this fold with target-specific costs/legality, then we
could do the transform more generally.

Differential Revision: https://reviews.llvm.org/D138873
2022-12-01 14:47:37 -05:00
Roman Lebedev
7850ab2112
[NFC] Port an assortment of tests that invoke SROA to new pass manager 2022-12-01 21:17:18 +03:00
Sanjay Patel
e71b81cab0 [InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1 (2nd try)
The first attempt was reverted because a clang test changed
unexpectedly - the file is already marked with a FIXME, so
I just updated it this time to pass.

Original commit message:
This is the main patch for converting a truncated scalar that is
inserted into a vector to bitcast+shuffle. We could go either way
on patterns like this, but this direction will allow collapsing a
pair of these sequences on the motivating example from issue

The patch is split into 3 parts to make it easier to see the
progression of tests diffs. We allow inserting/shuffling into a
different size vector for flexibility, so there are several test
variations. The length-changing is handled by shortening/padding
the shuffle mask with undef elements.

In part 1, handle the basic pattern:
inselt undef, (trunc T), IndexC --> shuffle (bitcast T), IdentityMask

Proof for the endian-dependency behaving as expected:
https://alive2.llvm.org/ce/z/BsA7yC

The TODO items for handling shifts and insert into an arbitrary base
vector value are implemented as follow-ups.

Differential Revision: https://reviews.llvm.org/D138872
2022-11-30 14:52:20 -05:00
Sanjay Patel
5eacdcff06 Revert "[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1"
This reverts commit a4c466766db77cd1fb42d7f98f32bb87a3d38829.
This broke clang tests that are wrongly dependent on the optimizer.
2022-11-30 14:10:50 -05:00
Sanjay Patel
a4c466766d [InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1
This is the main patch for converting a truncated scalar that is
inserted into a vector to bitcast+shuffle. We could go either way
on patterns like this, but this direction will allow collapsing a
pair of these sequences on the motivating example from issue

The patch is split into 3 parts to make it easier to see the
progression of tests diffs. We allow inserting/shuffling into a
different size vector for flexibility, so there are several test
variations. The length-changing is handled by shortening/padding
the shuffle mask with undef elements.

In part 1, handle the basic pattern:
inselt undef, (trunc T), IndexC --> shuffle (bitcast T), IdentityMask

Proof for the endian-dependency behaving as expected:
https://alive2.llvm.org/ce/z/BsA7yC

The TODO items for handling shifts and insert into an arbitrary base
vector value are implemented as follow-ups.

Differential Revision: https://reviews.llvm.org/D138872
2022-11-30 13:22:04 -05:00
Matt Arsenault
c4786139ac InstCombine: Add baseline tests for folding or of is.fpclass 2022-11-30 09:14:12 -05:00
Matt Arsenault
b611329491 InstCombine: Add baseline tests for negated is_fpclass 2022-11-30 09:13:30 -05:00
Matt Arsenault
5ec9403e79 InstCombine: Add baseline checks for is_fpclass 2022-11-30 09:05:37 -05:00
William Huang
be4b1dd35b [InstCombine] Revert D125845
Reverting D125845 `[InstCombine] Canonicalize GEP of GEP by swapping constant-indexed GEP to the back` because multiple users reported performance regression

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D138950
2022-11-29 22:02:40 +00:00
Bjorn Pettersson
0676acb6fd [test] Switch to use -passes syntax in a bunch of test cases
Should cover most of the tests for GVN, GVNHoist, GVNSink, GlobalOpt,
GlobalSplit, InstCombine, Reassociate, SROA and TailCallElim that
had not been updated earlier.
2022-11-29 13:29:02 +01:00
Mircea Trofin
255e7e1c21 [UpdateTestChecks] Fix update_*_test_checks.py to add "unused" prefixes
The support introduced in D124306 was only added to
update_llc_test_checks.py, but the motivating usecases (see
https://lists.llvm.org/pipermail/llvm-dev/2021-February/148326.html)
cover update_test_checks.py, update_cc_test_checks.py, and
update_analyze_test_checks.py, too.

Issue #59220.

Differential Revision: https://reviews.llvm.org/D138836
2022-11-28 13:24:32 -08:00
Roman Lebedev
4bcab22578
[NFC][InstCombine] Drop "unused" check prefixes in newly added test 2022-11-27 22:21:29 +03:00
Roman Lebedev
8a85fa68c7
Fixup last commit - actually stage check line updates 2022-11-27 21:58:36 +03:00
Roman Lebedev
242798c31c
[NFC][InstCombine] Add test coverage for potential fold 2022-11-27 21:57:43 +03:00
chenglin.bi
b400dde473 [InstSimplify] Use dominate condtion to simplify instructions
Fix #56795

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D138542
2022-11-26 21:41:41 +08:00
Matthias Gehre
5a1d92fa3e [InstCombine] Update debug intrinsics when rewriting allocas 2022-11-25 08:20:54 +01:00
Sanjay Patel
535c5d56a7 [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
2022-11-24 13:27:19 -05:00
Sanjay Patel
34b4672f92 [InstCombine] avoid 'tmp' variable name in tests; NFC
The auto-generation script warns on these files because
of the potential to conflict with the scripted regex names.
2022-11-24 12:22:40 -05:00
Sanjay Patel
56279164f3 [InstCombine] add tests for trunc+insertelt; NFC 2022-11-24 10:16:37 -05:00
Matt Arsenault
6463961941 InstCombine: Fold some identities for canonicalize
Equality is directly stated as true in the LangRef,
and I believe this works for every compare type.
2022-11-22 21:42:44 -05:00
Matt Arsenault
9ba3b61c15 InstCombine: Add baseline tests for canonicalize identities 2022-11-22 21:42:44 -05:00