45995 Commits

Author SHA1 Message Date
Koakuma
f63a19baf0 [SPARC] Add tail call support for 64-bit target
Extend SPARC tail call support, first introduced in D51206 (commit 1c235c375492180c2eecb6331f169486019fd2d2),
to also cover 64-bit target.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D138741
2022-11-26 23:29:05 -05:00
Roman Lebedev
25f01d593c
Revert "[SROA] isVectorPromotionViable(): memory intrinsics operate on vectors of bytes (take 2)"
TableGen is still getting miscompiled on PPC buildbots.
Sent a mail with request for help.

This reverts commit 3c4d2a03968ccf5889bacffe02d6fa2443b0260f.
2022-11-27 00:00:06 +03:00
Roman Lebedev
3c4d2a0396
[SROA] isVectorPromotionViable(): memory intrinsics operate on vectors of bytes (take 2)
This is a recommit of cf624b23bc5d5a6161706d1663def49380ff816a,
which was reverted in 5cfc22cafe3f2465e0bb324f8daba82ffcabd0df,
because the cut-off on the number of vector elements was not low enough,
and it triggered both SDAG SDNode operand number assertions,
and caused compile time explosions in some cases.

Let's try with something really *REALLY* conservative first,
just to get somewhere, and try to bump it (to 64/128) later.

FIXME: should this respect TTI reg width * num vec regs?

Original commit message:

Now, there's a big caveat here - these bytes
are abstract bytes, not the i8 we have in LLVM,
so strictly speaking this is not exactly legal,
see e.g. https://github.com/AliveToolkit/alive2/issues/860
^ the "bytes" "could" have been a pointer,
and loading it as an integer inserts an implicit ptrtoint.

But at the same time,
InstCombine's `InstCombinerImpl::SimplifyAnyMemTransfer()`
would expand a memtransfer of 1/2/4/8 bytes
into integer-typed load+store,
so this isn't exactly a new problem.

Note that in memory, poison is byte-wise,
so we really can't widen elements,
but SROA seems to be inconsistent here.

Fixes #59116.
2022-11-26 23:19:15 +03:00
Roman Lebedev
453f27bc9e
[AArch64] LowerBUILD_VECTOR(): NormalizeBuildVector() might return non-BUILD_VECTOR
As apparent in the newly-added test, provided in:
cf624b23bc (commitcomment-90836329),
we should be more careful with handling wider vectors,
or we will assert later on.
2022-11-26 18:46:36 +03:00
Craig Topper
64612f5d8e [RISCV] Add ADD to getRegAllocationHints to improve to improve use of c.add.
add can always be compressed to c.add if one of the sources is the
same as the destination.

The same is not true for c.addw where the registers need to be x8-x15.
2022-11-25 08:59:27 -08:00
Craig Topper
a2b5b584a5 [RISCV] Use register allocation hints to improve use of compressed instructions.
Compressed instructions usually require one of the source registers
to also be the source register. The register allocator doesn't have
that bias on its own.

This patch adds register allocation hints to introduce this bias.
I've started with ADDI, ADDIW, and SLLI. These all have a 5-bit
field for the register. If the source and dest register are the
same they are guaranteed to compress as long as the immediate is
also 6 bits.

This code was inspired by similar code from the SystemZ target.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D138242
2022-11-25 08:39:44 -08:00
Simon Pilgrim
c757780c62 [X86] lowerShuffleAsDecomposedShuffleMerge - try to match unpck(permute(x),permute(y)) for v4i32/v2i64 shuffles
We're using lowerShuffleAsPermuteAndUnpack, which can probably be improved to handle 256/512-bit types pretty easily.

First step towards trying to address the poor vector-shuffle-sse4a.ll pre-SSSE3 codegen mentioned on D127115
2022-11-25 16:24:56 +00:00
Simon Pilgrim
e95c119c3f [X86] oddshuffles.ll - update check-prefixes
Share AVX common prefix with XOP as well as AVX1/AVX2
2022-11-25 16:13:20 +00:00
LiaoChunyu
aa14f002d5 [RISCV] Branchless lowering for (select (x < 0), TrueConstant, FalseConstant) and (select (x >= 0), TrueConstant, FalseConstant)
This patch reduces the number of unpredictable branches

(select (x < 0), y, z)  -> x >> (XLEN - 1) & (y - z) + z
(select (x >= 0), y, z) -> x >> (XLEN - 1) & (z - y) + y

Reviewed By: craig.topper, reames

Differential Revision: https://reviews.llvm.org/D137949
2022-11-25 20:18:30 +08:00
Alex Richardson
d77b7cac27 [BPF] Avoid checking for intrinsics using string comparisons. NFC
Use a dyn_cast<> to IntrinsicInst and an enum compare instead.
While touching this code also re-generate the test to use positive check
lines instead of negative ones and remove some unneeded metadata.

Reviewed By: yonghong-song

Differential Revision: https://reviews.llvm.org/D138565
2022-11-25 11:34:55 +00:00
Simon Pilgrim
6fd0ae39be [X86] combineScalarAndWithMaskSetcc - handle (concat_vectors (and (vYi1 setcc, vYi1 x), undef)) patterns
If one of the AND operands is a setcc then we're implicitly zeroing the upper mask bits

Similar pattern to regressions identified in D127115 (masked comparisons)
2022-11-25 11:16:24 +00:00
Simon Pilgrim
b883e9f392 [X86] Add test case for (any_extend (bitcast (concat_vectors (and (vYi1 setcc, vYi1 x), undef)))) pattern
Similar pattern to a regression identified in D127115
2022-11-25 11:16:24 +00:00
Benjamin Maxwell
79b5829a15 [TargetLowering][AArch64] Teach DemandedBits about SVE count intrinsics
This allows DemandedBits to see that the SVE count intrinsics (CNTB,
CNTH, CNTW, CNTD) sans multiplier will only ever produce small
positive integers. The maximum value you could get here is 256, which
is CNTB on a machine with a 2048bit vector size (the maximum for SVE).

Using this various redundant operations (zexts, sexts, ands, ors, etc)
can be eliminated.

Differential Revision: https://reviews.llvm.org/D138424
2022-11-25 10:15:14 +00:00
Qiu Chaofan
b9be5a6823 Pre-commit PowerPC case for zero/inf fpclassify 2022-11-25 17:37:41 +08:00
Anton Sidorenko
8e3545a64e [Debugify] Accumulate the number of variables in debugify metadata
When a module contains more than one function, we should update debugify metadata
by increasing the number of variables in the function rather than overwritting it.

Previous revert issue is fixed: I forgot to strip all x86-related info from the
test.

Differential Revision: https://reviews.llvm.org/D136949
2022-11-25 10:53:55 +03:00
Krzysztof Parzyszek
d9ed93da86 [Hexagon] Don't lower legal EXTRACT_SUBVECTOR to EXTRACT_SUBREG
EXTRACT_SUBREG is a machine opcode and cannot be a part of an input
selection pattern.
2022-11-24 18:10:42 -08:00
Hassnaa Hamdi
5cf75ecf04 [AArch64][SME]: Generate streaming-compatible code for int/fp select/vselect
To generate code compatible to streaming mode:
 - enable custom lowering for VSETCC, needed for (fp-vselect.ll, int-vselect.ll).

Differential Revision: https://reviews.llvm.org/D138519
2022-11-24 18:19:13 +00:00
Hassnaa Hamdi
39641b1173 [AArch64][SME]: Add precursory tests for D138519
Add testing files:
 - fp-select.ll
 - int-select.ll
 - fp-vselect.ll
 - int-vselect.ll
2022-11-24 18:19:13 +00:00
Hassnaa Hamdi
f809f97a19 [AArch64][SME]: Generate streaming-compatible code for FP rounding operations.
1- To generate code compatible to streaming mode:
 - enable custom lowering for fcopysign, isd::fp_round, isd::fceil, isd::ffloor, isd::fnearbyint,
   isd::frint, isd::fround, isd::froundeven, isd::ftrunc.

Differential Revision: https://reviews.llvm.org/D138440
2022-11-24 17:45:17 +00:00
Hassnaa Hamdi
03fa1fedf1 [AArch64][SME]: Add precursory tests for D138440
Add testing files:
 - fcopysign.ll
 - fp-rounding.ll
2022-11-24 17:45:17 +00:00
Hassnaa Hamdi
5cc6963245 [AArch64][SME]: Generate streaming-compatible code for int-reduce, fp-reduce
1- To generate code compatible to streaming mode:
  - enable custom lowering for VECREDUCE_(smin, smax, umin, umax, add, fadd).

Differential Revision: https://reviews.llvm.org/D138309
2022-11-24 17:11:24 +00:00
Hassnaa Hamdi
e119a93d4e [AArch64][SME]: Add precursory tests for D138309
Add testing files:
 - int-reduce.ll
 - fp-reduce.ll
2022-11-24 17:11:23 +00:00
Simon Pilgrim
dbe2f44316 [X86] combineScalarAndWithMaskSetcc - optionally peek through (oneuse) any_extend node
Extend pass to handle: (and (any_extend (bitcast (vXi1 (concat_vectors (vYi1 setcc), undef,)))), C)

Fixes several regressions identified in D127115
2022-11-24 16:26:35 +00:00
Anton Sidorenko
5e04d8b72e Revert "[Debugify] Accumulate the number of variables in debugify metadata"
This brokes some builds
This reverts commit a1bbe8a4e2e50e7100dc17d9ddd1bfc3bfe44977.
2022-11-24 19:09:52 +03:00
Anton Sidorenko
a1bbe8a4e2 [Debugify] Accumulate the number of variables in debugify metadata
When a module contains more than one function, we should update debugify metadata
by increasing the number of variables in the function rather than overwritting it.

Differential Revision: https://reviews.llvm.org/D136949
2022-11-24 18:49:49 +03:00
Anton Sidorenko
0a77ff41da [Debugify] Precommit test for D136949 2022-11-24 18:17:11 +03:00
David Green
ca78b56014 [SelectOpt] Don't treat LogicalAnd/LogicalOr as selects
A `select i1 %c, i1 true, i1 %d` is just an or and a `select i1 %c, i1 %d, i1 false`
is just an and. There are better treated as such in the logic of SelectOpt, allowing
the backend to optimize them to and/or directly.

Differential Revision: https://reviews.llvm.org/D138490
2022-11-24 14:29:57 +00:00
Ivan Kosarev
ec8ede8177 [AMDGPU][CodeGen] Support raw format TFE buffer loads other than byte, short and d16 ones.
Differential Revision: https://reviews.llvm.org/D138215
2022-11-24 10:50:26 +00:00
Simon Pilgrim
6f11c395f5 [X86] combine-and.ll - add AVX2/AVX512 test coverage 2022-11-24 10:38:11 +00:00
Anton Sidorenko
9ee8d2e081 [Debugify] Strip llvm.mir.debugify metadata
We don't strip llvm.mir.debugify metadata in `llvm::stripDebugifyMetadata`. This
may lead to incorrect number of lines and variables in the metadata when we run
debugify twice, e.g. -run-pass=mir-debugify,...,mir-strip-debug,...,mir-debugify.

Differential Revision: https://reviews.llvm.org/D138417
2022-11-24 12:20:21 +03:00
Anton Sidorenko
782196409a [Debugify] Add precommit test for D138417
Check that we erase `llvm.debugify` metadata, but forget to erase `llvm.mir.debugify`.
2022-11-24 12:19:39 +03:00
wangpc
241accea2a [RISCV] Lower unmasked zero-stride vector load to (scalar load + splat)
So we have the opportunity to fold splat into .vx instruction as what
D101138 has done. If failed, we can select zero-stride vector load
again.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D138101
2022-11-24 11:09:45 +08:00
wangpc
25b51b7924 [RISCV] Precommit test for D138101
Add a test that splat can't be folded.

Reviewed By: pcwang-thead

Differential Revision: https://reviews.llvm.org/D138543
2022-11-24 11:07:19 +08:00
gonglingqin
eca62f9204 [LoongArch] Diagnose the behavior of reading and writing registers that do not conform to the hardware register size
When reading or writing a register that does not conform to the size of a
hardware register, an error message is generated instead of a compiler crash.

Differential Revision: https://reviews.llvm.org/D138008
2022-11-24 10:38:44 +08:00
Krzysztof Parzyszek
f8cb97a0f1 [Hexagon] Fix deinterleaving after vmpyh 2022-11-23 13:31:54 -08:00
Krzysztof Parzyszek
ae9356e8c4 [Hexagon] Fix order of operands in V6_vmpyhus
The unsigned operand is second: Vdd32.w = vmpy(Vu32.h,Vv32.uh)
2022-11-23 13:31:54 -08:00
Maryam Moghadas
934d5fa2b8 [PowerPC] Exploit xxperm, check for dead vectors and substitute vperm with xxperm
vperm instruction requires the data to be in the Altivec registers, if one of
the vector operands is not used after this vperm instruction then it can be
substituted by xxperm which doubles the number of available registers.

Reviewed By: stefanp

Differential Revision: https://reviews.llvm.org/D133700
2022-11-23 13:28:12 -06:00
Paulo Matos
bab98395a1 [WebAssembly] Remove unnecessary GEP insts from table tests
Removes the unnecessary GEP instructions from WebAssembly Table tests.

Differential Revision: https://reviews.llvm.org/D138569
2022-11-23 18:45:52 +01:00
Hassnaa Hamdi
10eda33a5f [AArch64][SME]: Generate streaming-compatible code for int-minmax, fp-minmax
1-To generate code compatible to streaming mode:
 - enable custom lowering for SMIN, SMAX, UMIN, UMAX,
   FMAXNUM, FMINNUM, FMAXIMUM, FMINIMUM.
2-Testing files:
 - int-minmax.ll
 - fp-minmax.ll

Reviewed By: david-arm, sdesmalen

Differential Revision: https://reviews.llvm.org/D138292
2022-11-23 15:49:16 +00:00
Hassnaa Hamdi
a5ee6e0836 [AArch64][SME]: Add precursory tests for D138292
Add testing files:
- int-minmax.ll
- fp-minmax.ll
2022-11-23 15:49:16 +00:00
Jonas Paulsson
ca51529487 [SystemZ] Extend combineGET_CCMASK() to handle a truncated SELECT_CCMASK.
In cases where the SELECT_CCMASK has an additional user of the carry, a
truncated SELECT_CCMASK may result as the input to the GET_CCMASK, which need
to be recognized.

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

Reviewed By: Ulrich Weigand

Differential Revision: https://reviews.llvm.org/D138324
2022-11-23 09:53:07 -05:00
Benjamin Kramer
5cfc22cafe Revert "[SROA] isVectorPromotionViable(): memory intrinsics operate on vectors of bytes"
This reverts commit cf624b23bc5d5a6161706d1663def49380ff816a. It
triggers crashes in clang, see the comments on github on the original
change.
2022-11-23 13:11:16 +01:00
zhongyunde
3651bc83b6 [AArch64] Optimize cmp chain before legalization
* For case bcmp9, there is extras AND and EXTEND int the chain of OR/XOR,
  which prevent the transform, so enable the optimize before legalization.

* The key IR frag related:
      t37: i32,ch = load<(load (s8) from %ir.4), anyext from i8> t0, t11, undef:i64
        t12: i64 = add t4, Constant:i64<8>
      t38: i32,ch = load<(load (s8) from %ir.5), anyext from i8> t0, t12, undef:i64
    t39: i32 = xor t37, t38
  t40: i64 = any_extend t39
t42: i64 = and t40, Constant:i64<255>

Depends on D138398 to fix combine_setcc_glue

Reviewed By: dmgreen, bcl5980
Differential Revision: https://reviews.llvm.org/D137936
2022-11-23 19:43:44 +08:00
Alex Richardson
88218d5c52 [SelectionDAG] Remove deprecated MemSDNode->getAlignment()
I noticed a an assertion error when building MIPS code that loaded from
NULL. Loading from NULL ends up being a load with maximum alignment, and
due to integer truncation the value maximum was interpreted as 0 and the
assertion in MipsDAGToDAGISel::Select() failed. This previously happened
to work, but the maximum alignment was increased in
df84c1fe78130a86445d57563dea742e1b85156a, so it no longer fits into a 32
bit integer.
Instead of just fixing the one MIPS case, this patch removes all uses of
the deprecated getAlignment() call and replaces them with getAlign().

Differential Revision: https://reviews.llvm.org/D138420
2022-11-23 09:04:42 +00:00
Ruiling Song
0eaf6759ae [AMDGPU][InsertWaits] No wait for WAW for global/scratch_load
global/scratch_load will return in order they are issued. No
need to insert a s_waitcnt for WAW hazard.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D138476
2022-11-23 09:57:50 +08:00
Phoebe Wang
7218103bca [X86] Use lock add/sub/or/and/xor for cases that we only care about the EFLAGS (negated cases)
This fixes #58685

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D138428
2022-11-23 09:39:04 +08:00
Ben Shi
f452b9dcaf [AVR] Fix wrong ABI of AVRTiny.
A scalar which exceeds 4 bytes should be returned via stack, other
than via registers, on an AVRTiny device.

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D138201
2022-11-23 09:32:47 +08:00
chenglin.bi
cdb7b804f6 [DAGCombiner] fold or (xor x, y),? patterns
or (xor x, y), x --> or x, y
or (xor x, y), y --> or x, y
or (xor x, y), (and x, y) --> or x, y
or (xor x, y), (or x, y) --> or x, y

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D138401
2022-11-23 09:28:10 +08:00
Roman Lebedev
cf624b23bc
[SROA] isVectorPromotionViable(): memory intrinsics operate on vectors of bytes
Now, there's a big caveat here - these bytes
are abstract bytes, not the i8 we have in LLVM,
so strictly speaking this is not exactly legal,
see e.g. https://github.com/AliveToolkit/alive2/issues/860
^ the "bytes" "could" have been a pointer,
and loading it as an integer inserts an implicit ptrtoint.

But at the same time,
InstCombine's `InstCombinerImpl::SimplifyAnyMemTransfer()`
would expand a memtransfer of 1/2/4/8 bytes
into integer-typed load+store,
so this isn't exactly a new problem.

Note that in memory, poison is byte-wise,
so we really can't widen elements,
but SROA seems to be inconsistent here.

Fixes #59116.
2022-11-23 02:38:25 +03:00
Roman Lebedev
11c2c163de
[NFC][AMDGPU] Rewrite two test files to avoid completely simplifying away after next patch 2022-11-23 02:38:25 +03:00