42810 Commits

Author SHA1 Message Date
Kai Nacke
30053c1445 [SystemZ/z/OS] Add va intrinsics for XPLINK
Add support for va intrinsics for the XPLINK ABI.
Only the extended vararg variant, which uses a pointer to next
argument, is supported. The standard variant will build on this.

Reviewed By: uweigand

Differential Revision: https://reviews.llvm.org/D120148
2022-02-22 14:35:05 -05:00
Reid Kleckner
ecb27004ec Revert "[AArch64] Alter mull shuffle(ext(..)) combine to work on buildvectors"
This reverts commit 9fc1a0dcb79afb31470751651c30e843c12e9ca5.

We have bisected a compiler crash to this revision and will provide a
test case soon.
2022-02-22 10:31:09 -08:00
Stanislav Mekhanoshin
9e055c0fff [AMDGPU] Extend SILoadStoreOptimizer to handle global saddr loads
This adds handling of the _SADDR forms to the GLOBAL_LOAD combining.

TODO: merge global stores.
TODO: merge flat load/stores.
TODO: merge flat with global promoting to flat.

Differential Revision: https://reviews.llvm.org/D120285
2022-02-22 09:01:43 -08:00
Stanislav Mekhanoshin
ba17bd2674 [AMDGPU] Extend SILoadStoreOptimizer to handle global loads
There can be situations where global and flat loads and stores are not
combined by the vectorizer, in particular if their address space
differ in the IR but they end up the same class instructions after
selection. For example a divergent load from constant address space
ends up being the same global_load as a load from global address space.

TODO: merge global stores.
TODO: handle SADDR forms.
TODO: merge flat load/stores.
TODO: merge flat with global promoting to flat.

Differential Revision: https://reviews.llvm.org/D120279
2022-02-22 08:42:36 -08:00
Nikita Popov
e075bf6bdb [CodeGen] Add test for PR53990 (NFC) 2022-02-22 16:32:20 +01:00
Simon Moll
4fd77129f2 [VE] Split unsupported v512.32 ops
Split v512.32 binary ops into two v256.32 ops using packing support
opcodes (vec_unpack_lo|hi, vec_pack).

Depends on D120053 for packing opcodes.

Reviewed By: kaz7

Differential Revision: https://reviews.llvm.org/D120146
2022-02-22 14:29:41 +01:00
Paul Walker
25ed2ab341 [SVE] Add isel patterns for SABA/UABA.
Differential Revision: https://reviews.llvm.org/D119830
2022-02-22 13:09:57 +00:00
Sanjay Patel
ad7214f23d [x86] add load folding restriction to pushAddIntoCmovOfConsts()
With only a load-fold the diffs look neutral. If there's a load and store (rmw)
fold opportunity as shown in the test based on #53862, then we end up with an
extra instruction.

Fixes #53862

Differential Revision: https://reviews.llvm.org/D120281
2022-02-22 08:02:11 -05:00
Sunho Kim
d6a9eec238 [AARCH64][DAGCombine] Add combine for negation of CSEL absolute value pattern.
This folds a negation through a csel, which can come up during the
lowering of negative abs.

Fixes https://github.com/llvm/llvm-project/issues/51558.

Differential Revision: https://reviews.llvm.org/D112204
2022-02-22 09:59:36 +00:00
Sunho Kim
321a39b755 [NFC][AARCH64] Add test cases for negation of select
Add tests to demonstrate new dag combine pattern.

Differential Revision: https://reviews.llvm.org/D120214
2022-02-22 09:26:47 +00:00
jacquesguan
5acd9c49a8 [RISCV] Add patterns for vector widening integer reduction instructions
Add patterns for vector widening integer reduction instructions.

Differential Revision: https://reviews.llvm.org/D117643
2022-02-22 14:14:05 +08:00
Joseph Huber
456ffd7a22 [OpenMP] Ensure offloading sections do not have SHF_ALLOC flag
We use offloading sections in the new Clang driver scheme to embed
device code into the host. We later use these sections to link the
device image, after which point they are completely unused and should
not be loaded into memory if they are still in the executable.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D120275
2022-02-21 21:35:17 -05:00
Lian Wang
294072e10b [RISCV] Add more tests for SHLFI and UNSHFLI aliaes in Zbp extension
RV32/RV64:
zip.n/zip2.b/zip.b/zip4.h/zip2.h/zip.h
unzip.n/unzip2.b/unzip.b/unzip4.h/unzip2.h/unzip.h

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D120241
2022-02-22 02:20:32 +00:00
Zakk Chen
f7dfc5d1af [RISCV] Optimize tail agnostic vmv.s.x which don't need to select tail value.
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D120250
2022-02-21 14:53:37 -08:00
Vang Thao
3a17a81773 [AMDGPU] Regenerate tests to include -NEXT. NFC. 2022-02-21 14:14:53 -08:00
Sanjay Patel
6766ece133 [x86] add tests for rmw add with cmov; NFC 2022-02-21 16:34:05 -05:00
Craig Topper
90d240553d [RISCV] Teach shouldSinkOperands to sink splat operands of vp.fma intrinsics.
Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D120167
2022-02-21 11:52:59 -08:00
David Green
4d5b020d6e [ARM] Addition SSAT/USAT tests for min/max patterns. NFC 2022-02-21 16:24:58 +00:00
David Green
9fc1a0dcb7 [AArch64] Alter mull shuffle(ext(..)) combine to work on buildvectors
We have a combine for converting mul(dup(ext(..)), ...) into
mul(ext(dup(..)), ..), for allowing more uses of smull and umull
instructions. Currently it looks for vector insert and shuffle vectors
to detect the element that we can convert to a vector extend. Not all
cases will have a shufflevector/insert element though.

This started by extending the recognition to buildvectors (with elements
that may be individually extended). The new method seems to cover all
the cases that the old method captured though, as the shuffle will
eventually be lowered to buildvectors, so the old method has been
removed to keep the code a little simpler. The new code detects legal
build_vector(ext(a), ext(b), ..), converting them to ext(build_vector(a,
b, ..)) providing all the extends/types match up.

Differential Revision: https://reviews.llvm.org/D120018
2022-02-21 15:44:30 +00:00
Matt Arsenault
9c7ca51b2c MIR: Start diagnosing too many operands on an instruction
Previously this would just assert which was annoying and didn't point
to the specific instruction/operand.
2022-02-21 10:36:39 -05:00
Sanjay Patel
bb850d422b [AArch64][RISCV][x86] add tests for funnel shift with shift logic; NFC 2022-02-21 10:24:45 -05:00
Simon Pilgrim
d41bf28781 [X86] use-cr-result-of-dom-icmp-st.ll - add checks without -cgp-icmp-eq2icmp-st flag 2022-02-21 13:44:47 +00:00
Florian Hahn
55c181a6c7
Revert "[AArch64][GlobalISel] Optimize conjunctions of compares to conditional compares."
This reverts commit 2a46450849de6904fc64f9a65303b20ca7fc9dbd.

This triggers the following assertion in an internal project:

    Assertion failed: (VRegInfo[Reg.id()].first.is<const TargetRegisterClass
    *>() && "Register class not set, wrong accessor"), function getRegClass,
    file MachineRegisterInfo.h, line 646.

I'll work with the author directly to get a reproducer.
2022-02-21 10:52:10 +00:00
Jay Foad
359a792f9b [AMDGPU] SILoadStoreOptimizer: avoid unbounded register pressure increases
Previously when combining two loads this pass would sink the
first one down to the second one, putting the combined load
where the second one was. It would also sink any intervening
instructions which depended on the first load down to just
after the combined load.

For example, if we started with this sequence of
instructions (code flowing from left to right):

  X A B C D E F Y

After combining loads X and Y into XY we might end up with:

  A B C D E F XY

But if B D and F depended on X, we would get:

  A C E XY B D F

Now if the original code had some short disjoint live ranges
from A to B, C to D and E to F, in the transformed code
these live ranges will be long and overlapping. In this way
a single merge of two loads could cause an unbounded
increase in register pressure.

To fix this, change the way the way that loads are moved in
order to merge them so that:
- The second load is moved up to the first one. (But when
  merging stores, we still move the first store down to the
  second one.)
- Intervening instructions are never moved.
- Instead, if we find an intervening instruction that would
  need to be moved, give up on the merge. But this case
  should now be pretty rare because normal stores have no
  outputs, and normal loads only have address register
  inputs, but these will be identical for any pair of loads
  that we try to merge.

As well as fixing the unbounded register pressure increase
problem, moving loads up and stores down seems like it
should usually be a win for memory latency reasons.

Differential Revision: https://reviews.llvm.org/D119006
2022-02-21 10:51:14 +00:00
Lian Wang
2e153038b4 [RISCV] Add tests for SHFLI and UNSHFLI aliases in Zbp extension
Supplement tests alias of SHFLI and UNSHFLI instructions.

RV32: zip8/zip4/zip2/unzip8/unzip4/unzip2

RV64: zip8.w/zip4.w/zip2.w/zip.w/zip8/zip4/zip2/zip/
      unzip8.w/unzip4.w/unzip2.w/unzip.w/unzip8/unzip4/unzip2/unzip

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D120015
2022-02-21 10:10:32 +00:00
Simon Moll
cf964eb5bd [VE] v512i1 mask arithmetic isel
Packed vector and mask registers (v512) are composed of two v256
subregisters that occupy the even and odd element positions.  We add
packing support SDNodes (vec_unpack_lo|hi and vec_pack) and splitting of
v512i1 mask arithmetic ops with those.

Reviewed By: kaz7

Differential Revision: https://reviews.llvm.org/D120053
2022-02-21 10:38:11 +01:00
Craig Topper
a6fb1bb306 [ARM] Remove unused lowerABS function. NFC
This function was added in D49837, but no setOperationAction call
was added with it. The code is equivalent to what is done by the
default ExpandIntRes_ABS implementation when ADDCARRY is supported.
Test case added to verify this. There was some existing coverage
from Thumb2 MVE tests, but they started from vectors.
2022-02-20 22:43:23 -08:00
Craig Topper
440c4b705a [SelectionDAG][RISCV][ARM][PowerPC][X86][WebAssembly] Change default abs expansion to use sra (X, size(X)-1); sub (xor (X, Y), Y).
Previous we used sra (X, size(X)-1); xor (add (X, Y), Y).

By placing sub at the end, we allow RISCV to combine sign_extend_inreg
with it to form subw.

Some X86 tests for Z - abs(X) seem to have improved as well.

Other targets look to be a wash.

I had to modify ARM's abs matching code to match from sub instead of
xor. Maybe instead ISD::ABS should be made legal. I'll try that in
parallel to this patch.

This is an alternative to D119099 which was focused on RISCV only.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D119171
2022-02-20 21:11:23 -08:00
Serguei Katkov
7f2293ba25 [STATEPOINT] Mark LR is early-clobber implicit def.
LR is modified at the moment of the call and before any use is read.

Reviewers: reames
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D120114
2022-02-21 10:37:43 +07:00
esmeyi
7b67d2e398 Reland [XCOFF][llvm-objdump] change the priority of symbols with the same address by symbol types.
Fix the Buildbot failure #19373.

Differential Revision: https://reviews.llvm.org/D117642
2022-02-20 21:51:10 -05:00
Luo, Yuanke
67ef63138b [SDAG] enable binop identity constant folds for sub
This patch extract the sub folding from D119654 and leave only add
folding in that patch.

Differential Revision: https://reviews.llvm.org/D120116
2022-02-21 09:37:36 +08:00
Simon Pilgrim
d0505201c4 [X86] Regenerate switch-default-only.ll 2022-02-20 20:42:36 +00:00
Sanjay Patel
7f827ebddc [AArch64][RISCV][x86] add tests for mul-add demanded bits; NFC
See #53829
2022-02-20 15:06:55 -05:00
Simon Pilgrim
ec910751fe [X86] combineX86ShufflesRecursively - attempt to fold ISD::EXTRACT_SUBVECTOR into a shuffle chain
Peek through if we're extracting a non-zero'th subvector in an attempt to fold the extract into a lane-crossing shuffle

This also exposes a failure to fold extract_subvector(movddup(x),c) -> movddup(extract_subvector(x,c))
2022-02-20 18:50:33 +00:00
David Green
147b97de90 [AArch64] Extra tests for larger umull/smull generation. NFC 2022-02-20 13:20:34 +00:00
Amara Emerson
2a46450849 [AArch64][GlobalISel] Optimize conjunctions of compares to conditional compares.
This is a partial port of the same optimization from AArch64ISelLowering,
although the original handles more cases when generating regular compares
instead of this one which just does it when selecting G_SELECTs.

For more detailed comments see the original comments for
emitConditionalComparison() in AArch64ISelLowering.

Gives minor code size improvements.

Differential Revision: https://reviews.llvm.org/D117166
2022-02-20 01:13:34 -08:00
Amara Emerson
b09e63bad1 [AArch64][GlobalISel] Implement combines for boolean G_SELECT->bitwise ops.
Differential Revision: https://reviews.llvm.org/D117160
2022-02-20 00:53:09 -08:00
Simon Pilgrim
55e0b388d0 [X86] vector-reduce-add-mask.ll - add missing AVX512BW/BWVL check prefixes 2022-02-19 20:19:54 +00:00
Simon Pilgrim
d5304d44a5 [X86] Extend bswap+shl tests
Different shift amounts and multiuse tests
2022-02-19 19:16:56 +00:00
Simon Pilgrim
ebeb191b65 [X86] Add bswap(shl()) test
Test based off issues #51391 and #53867 - we're going to end up needing InstCombine + DAG variants of this fold as DAG can create BSWAP nodes as part of load folding
2022-02-19 17:37:07 +00:00
Simon Pilgrim
f6ee45e943 [X86] Add some add reduction tests for values that are zero in the upper bits
This is an extension of some of the tests mentioned in Issue #42019 - we might be able to use PSADBW to add+zext 4 x bytes to i64 that can then be reduced
2022-02-19 15:36:21 +00:00
Micah Weston
c69af70f02 [AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.
Implements ADDS/SUBS 24-bit immediate optimization using the
MIPeepholeOpt pass. This follows the pattern:

Optimize ([adds|subs] r, imm) -> ([ADDS|SUBS] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([adds|subs] r, imm) -> ([SUBS|ADDS] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The SplitAndOpcFunc type had to change the return type to an Opcode pair so that
the first add/sub is the regular instruction and the second is the flag setting
instruction. This required updating the code in the AND case.

Testing:

I ran a two stage bootstrap with this code.
Using the second stage compiler, I verified that the negation of an ADDS to SUBS
or vice versa is a valid optimization. Example V == -0x111111.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D118663
2022-02-19 15:35:53 +00:00
David Green
b8801ba050 [AArch64] Common patterns between UMULL and int_aarch64_neon_umull
We have some duplicate patterns between the AArch64ISD::UMULL (/SMULL)
and the int_aarch64_neon_umull (/smull) intrinsics. They did not
replicate all the patterns though, leaving some gaps on instructions
like umlal2 from codegen. This commons all the patterns by converting
all int_aarch64_neon_umull intrinsics to UMULL nodes and removing the
duplicate for umull/smull intrinsics, so that all instructions go
through the same tablegen pattern.

This improves some of the longer-than-legal mla patterns, helping them
replace ext with umlal2.

Differential Revision: https://reviews.llvm.org/D119887
2022-02-19 14:38:57 +00:00
Craig Topper
5489969550 [RISCV] Add IsRV32 to the isel pattern for ZIP_RV32/UNZIP_RV32. NFC
I think the i32 in the pattern prevents this from matching on RV64,
but using IsRV32 is safer.

Add tests for RV64 to make sure we don't print zip or unzip
because we incorrectly picked ZIP_RV32/UNZIP_RV32.
2022-02-18 22:38:14 -08:00
Craig Topper
1df8efae56 [SelectionDAG][X86] Support f16 in getReciprocalOpName.
If the "reciprocal-estimates" attribute is present and it doesn't
contain "all", "none", or "default", we previously crashed on f16
operations.

This patch addes an 'h' suffix' to prevent the crash.

I've added simple tests that just enable the estimate for all
vec-sqrt and one test case that explicitly tests the new 'h' suffix
to override the default steps.

There may be some frontend change needed to, but I haven't checked
that yet.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D120158
2022-02-18 21:55:49 -08:00
Weining Lu
efb383266d [LoongArch] Fix atomic instructions operands sequence
According to https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#atomic-memory-access-instructions,
the operands sequence of am* instructions should be "rd, rk, rj"
but not "rd, rj, rk". Sorry for this typo in initial patches.

Reviewed By: xen0n, MaskRay

Differential Revision: https://reviews.llvm.org/D120107
2022-02-19 09:22:10 +08:00
Craig Topper
0d59a54cea Revert "[SelectionDAG][X86] Support f16 in getReciprocalOpName."
This reverts commit 86b5e256628ae49193ad9962626a73bafeda2883.

This wasn't supposed to be commited yet
2022-02-18 15:39:50 -08:00
Craig Topper
86b5e25662 [SelectionDAG][X86] Support f16 in getReciprocalOpName.
If the "reciprocal-estimates" attribute is present and it doesn't
contain "all", "none", or "default", we previously crashed on f16
operations.

This patch addes an 'h' suffix' to prevent the crash.

I've added simple tests that just enable the estimate for all
vec-sqrt and one test case that explicitly tests the new 'h' suffix
to override the default steps.

There may be some frontend change needed to, but I haven't checked
that yet.

Differential Revision: https://reviews.llvm.org/D120158
2022-02-18 15:36:35 -08:00
Sanjay Patel
a2963d871e [SDAG] fold sub-of-shift to add-of-shift
This fold is done in IR:
https://alive2.llvm.org/ce/z/jWyFrP

There is an x86 test that shows an improvement
from the added flexibility of using add (commutative).

The other diffs are presumed neutral.

Note that this could also be folded to an 'xor',
but I'm not sure if that would be universally better
(eg, x86 can convert adds more easily into LEA).

This helps prevent regressions from a potential fold for
issue #53829.
2022-02-18 11:55:50 -05:00
Jay Foad
f510045d82 [CodeGen] Remove unneeded regex escaping in FileCheck patterns. NFC.
Take advantage of D117117 to simplify all {{\[}} to [ and {{\]}} to ].

Differential Revision: https://reviews.llvm.org/D117298
2022-02-18 16:10:56 +00:00