46087 Commits

Author SHA1 Message Date
Bill Wendling
14d4cddc55 [X86] Don't zero out %eax if both %al and %ah are used
The iterator over super and sub registers doesn't include both 8-bit
registers in its list. So if both registers are used and only one of
them is live on return, then we need to make sure that the other 8-bit
register is also marked as live and not zeroed out.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D139679
2022-12-13 15:06:53 -08:00
Roman Lebedev
692d46d839
[NFC][X86][Codegen] Fix test coverage for AVX512 i1 mask replication
At least some of the seemingly-bad codegen was because we really need to
consume the replicated i1 mask by the mask-consuming instruction
if we want faithful codegen for the replication shuffle.

But some of the odd codegen is still there.
2022-12-14 01:50:53 +03:00
Koakuma
eaade37fdd [SPARC] Mark the %g0 register as constant & use it to materialize zeros
Materialize zeros by copying from %g0, which is now marked as constant.

This makes it possible for some common operations (like integer negation) to be
performed in fewer instructions.

This continues @arichardson's patch at D132561.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D138887
2022-12-13 17:25:42 -05:00
Philip Reames
668cde81df [RISCV] Reuse VL (if non-zero) when building single element vector for start of reduction chain
This is an alternative patch on a path to D137530.

The basic problem being tackled here is that we need to place a scalar into lane 0 of a vector register before our reduction instructions. Since we only care about lane 0 of the vector, we can use any VL >= 1 provided that the total amount of work performed matches the work performed for a VL=1.

This change does not contain the logic from D137530 to perform the insert at the original VT, and then extract down to LMUL1. That turns out to be a good choice, as discussion in this review has indicated there are issues around LMUL2 and above with our representation of vmv.s.x. We'd also need to be careful with the splat logic for the same reasons.

The only potentially concerning codegen change I spot here is that we stop using a broadcast load (for VL=1) and instead do a scalar load and insert. I think this is probably reasonable; if reviewers disagree, I can investigate using a broadcast load which writes to the undef lanes. If we want to do that, we should do it for VECTOR_INSERT_ELT as well, so that'll end up as it's own patch series.

Differential Revision: https://reviews.llvm.org/D139656
2022-12-13 12:16:26 -08:00
Josh Stone
9b8fcd04ef [X86] Fix cmp order in probing BuildStackAlignAND
Due to reversed arguments, the loop start was almost always skipping the
whole loop, since FinalStackProbed is probably less than StackPtr for
large alignments. The intent was to skip the loop if the first sub on
StackPtr made it less than FinalStackProbed already, so flip it.

Reviewed By: serge-sans-paille

Differential Revision: https://reviews.llvm.org/D139756
2022-12-13 12:10:39 -08:00
Rahman Lavaee
96b6ee1bdc Revert "[Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number."
This reverts commit 6015a045d768feab3bae9ad9c0c81e118df8b04a.

Differential Revision: https://reviews.llvm.org/D139952
2022-12-13 11:13:57 -08:00
Roman Lebedev
31879765d8
[NFC][X86][Codegen] Add codegen test coverage for i1 mask replication (AVX512 only)
Apparently i didn't add it when adding cost model coverage?
2022-12-13 21:21:07 +03:00
Craig Topper
844430bcc3 [RISCV] Add support for call returns to RISCVSExtWRemoval.
The implementation is inspired by code from PPCInstrInfo.

We look for a copy from X10(A0) preceded by an ADJCALLSTACKUP and
a PseudoCall. We use the PseudoCall to look up the IR function being
called to find it's return attributes.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D139808
2022-12-13 09:09:13 -08:00
Sameer Sahasrabuddhe
6a2305484e [AAPointerInfo] track multiple constant offsets for each use
An expression of the form `gep(base, select(pred, const1, const2))` can result
in a set of offsets instead of just one. PointerInfo can now track these sets
instead of conservatively modeling them as Unknown. In general, AAPointerInfo
now uses AAPotentialConstantValues to examine the operands of the GEP.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D138646
2022-12-13 22:27:25 +05:30
Pavel Kopyl
619b7cecf3 [NVPTX] Backend support for variadic functions
This patch adds lowering for function calls with variadic number of
arguments as well as enables support for the following
instructions/intrinsics:

  - va_arg
  - va_start
  - va_end
  - va_copy

Note that this patch doesn't intent to include clang's support for
variadic functions for CUDA.

According to the docs:

  PTX version 6.0 supports passing unsized array parameter to a
  function which can be used to implement variadic functions. [0]

  The last parameter in the parameter list may be a .param array of
  type .b8 with no size specified. It is used to pass an arbitrary
  number of parameters to the function packed into a single array
  object.

  When calling a function with such an unsized last argument, the last
  argument may be omitted from the call instruction if no parameter is
  passed through it.  Accesses to this array parameter must be within
  the bounds of the array.  The result of an access is undefined if no
  array was passed, or if the access was outside the bounds of the
  actual array being passed. [1]

Note that aggregates passed by value as variadic arguments are not
currently supported.

[0] https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#variadic-functions
[1] https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#kernel-and-function-directives-func

Differential Revision: https://reviews.llvm.org/D138531
2022-12-13 19:07:43 +03:00
Philip Reames
8adde6941a [RISCV] Use vmv.v.i for insertion into lane 0 of undef vector when profitable
If we're initializing lane 0 of an undef vector, we can optionally write to other lanes of the vector. Doing so may require additional work, so we don't want to e.g. always use a splat. However, since we don't have an immediate form of vmv.s.x it's useful to use a vmv.v.i if the work required is expected to be equal in practice.  We restrict this to when LMUL <= 1 to a) prevent doing additional work at higher LMULs, and b) avoid overconstraining the register allocator.

At the moment, the new utility is only used by one case in INSERT_VECTOR_ELT lowering. My expectation is that we will reuse this in a couple other places, but each of those deserve individual review.

This change is inspired by D137530, but is not directly related to it. I vaguely remember we discussed the tradeoffs of using vmv.v.i in another recent review, but couldn't find it.

Differential Revision: https://reviews.llvm.org/D139648
2022-12-13 07:54:46 -08:00
Pierre van Houtryve
9fa46200ea [AMDGPU] Add .workgroup_processor_mode to v5 MD
Adds Workgroup Processor Mode (WGP) to the HSA Metadata for Code Object v5/GFX10+.
The field is already present as an asm directive and in the compute program resource register but is also needed in the MD.

Reviewed By: kzhuravl

Differential Revision: https://reviews.llvm.org/D139931
2022-12-13 10:44:52 -05:00
Pierre van Houtryve
678d8946ba [AMDGPU] Add bf16 storage support
- [Clang] Declare AMDGPU target as supporting BF16 for storage-only purposes on amdgcn
  - Add Sema & CodeGen tests cases.
  - Also add cases that D138651 would have covered as this patch replaces it.
- [AMDGPU] Add BF16 storage-only support
  - Support legalization/dealing with bf16 operations in DAGIsel.
  - bf16 as a type remains illegal and is represented as i16 for storage purposes.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D139398
2022-12-13 10:34:26 -05:00
Simon Pilgrim
4177e6cd4f [X86] lowerShuffleAsVTRUNC - support offseted truncations
Extend the <0,Scale,2*Scale,..> pattern to allow for a fixed offset <Offset,Offset+Scale,Offset+2*Scale,..> pattern, which will lower to a single additional bitshift/pshufd.

At the moment I've limited this to cases where the LHS/RHS operands are concatenated for free, but this is only to avoid a couple of regressions that should be easily addressable in followups.
2022-12-13 14:00:35 +00:00
Alexey Baturo
54e72dd4eb re-land [RISC-V][HWASAN] Support tagging global variables for RISC-V HWASAN
Now with fix to limit added tagged-globals.ll to risc-v platform
--
[RISC-V][HWASAN] Support tagging global variables for RISC-V HWASAN

Reviewed by: luismarques

Differential Revision: https://reviews.llvm.org/D132995
2022-12-13 15:51:51 +03:00
Alexey Baturo
5e89876538 Revert "[RISC-V][HWASAN] Support tagging global variables for RISC-V HWASAN"
This reverts commit 11937ca5642216a67e021e69fc824f709267bada.
2022-12-13 15:17:40 +03:00
Alexey Baturo
11937ca564 [RISC-V][HWASAN] Support tagging global variables for RISC-V HWASAN
Reviewed by: luismarques

Differential Revision: https://reviews.llvm.org/D132995
2022-12-13 14:57:34 +03:00
Martin Storsjö
899739cdbd Revert "[AArch64][GlobalISel] Lower formal arguments of AAPCS & ms_abi variadic functions."
This reverts commit 56fd846f370adf16bea333b12637038ea2f3c225.

This commit regressed handling of functions with floats as arguments,
reproducible e.g. like this:

$ cat test.c
double func(double f) {
    return f;
}
$ clang -target aarch64-windows -S -o - test.c -fno-asynchronous-unwind-tables
func:
	sub	sp, sp, #16
	str	x0, [sp, #8]
	ldr	d0, [sp, #8]
	add	sp, sp, #16
	ret
2022-12-13 11:37:35 +02:00
esmeyi
d4fd275896 [NFC][PowerPC] Add tests for 64-bit constants that require 5 instructions to materialize.
Differential Revision: https://reviews.llvm.org/D139914
2022-12-13 02:44:49 -05:00
wanglei
899226adac [LoongArch] Add custom parser for atomic instructions' memory operand
In order to be compatible with the form of the atomic instruction in
GAS that accepts the fourth operand as 0 (i.e. `am* $rd, $rk, $rj, 0`),
we need to treat `$rj, 0` as one operand, but only print `$rj`.

For this, the number of result operands of inline assembly memory
operand `ZB` constraint is modified to 2 (reg + 0).

Restrictions on register usage in `am*` instructions have also been
adjusted. When `$rd` is equal to `$r0`, the instruction must be
considered legal, because of some special usage like `PseudoUNIMP`.

Reviewed By: SixWeining, xen0n

Differential Revision: https://reviews.llvm.org/D139303
2022-12-13 11:46:53 +08:00
Matt Arsenault
4f63f9739c AMDGPU: Add sanity test if amdgcn.device.{init|fini} already exists 2022-12-12 22:18:37 -05:00
Matt Arsenault
d647e252b8 InstSimplify: Add basic folding of llvm.is.fpclass intrinsic
Copied from the existing llvm.amdgcn.class handling; eventually I will
fold that to the generic intrinsic when legal. The tests should
probably move into an instsimplify only test.
2022-12-12 21:54:04 -05:00
Roman Lebedev
6893b15190
[NFC][Codegen][X86] Revisit interleaved store codegen tests
This matches the coverage with the Costmodel tests,
adds stride 5/7/8, and improves AVX512 checks.

I *think* i've compressed check prefixes
as much as possible, but it's a bit hard to tell.
But hey, at one no longer has to fight against FileCheck+UTC :).
2022-12-13 04:25:54 +03:00
Roman Lebedev
a13a2d105b
[NFC][Codegen][X86] Add higher-VF interleaved load codegen tests that got lost 2022-12-13 04:25:54 +03:00
Ting Wang
e6d925bc4b [PowerPC][NFC] Add test case for memset tail store
Add test case to show something can be improved.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D138881
2022-12-12 20:07:23 -05:00
Roman Lebedev
f7cdcc2884
[NFC][Codegen][X86] Revisit interleaved load codegen tests
This matches the coverage with the Costmodel tests,
adds stride 5/7/8, and improves AVX512 checks.

I *think* i've compressed check prefixes
as much as possible, but it's a bit hard to tell.
But hey, at one no longer has to fight against FileCheck+UTC :).
2022-12-13 03:40:21 +03:00
Doru Bercea
aea5980e26 Emit CAS loop for min/max atomics. 2022-12-12 11:42:30 -06:00
Philip Reames
a4b45c28a1 [RISCV] Allow fractional LMUL for reduction start value
For reductions, we need to put the start value into a source vector. For fractional LMULs, we can perform the operation at the original LMUL.  For LMUL > 1, we eventually want to use a scalar insert, but that's outside the scope of this patch.

Differential Revision: https://reviews.llvm.org/D139747
2022-12-12 09:08:21 -08:00
Jay Foad
81084bfa2c [AMDGPU] Make use of !listremove. NFCI.
This only affects the order of implicit operands in some MIR tests.

Differential Revision: https://reviews.llvm.org/D139829
2022-12-12 17:01:04 +00:00
Vladislav Dzhidzhoev
56fd846f37 [AArch64][GlobalISel] Lower formal arguments of AAPCS & ms_abi variadic functions.
Reimplemented SelectionDAG code for GlobalISel.

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

Differential Revision: https://reviews.llvm.org/D130903
2022-12-12 19:35:40 +03:00
Roman Lebedev
1bd0b82e50
[SimplifyCFG] FoldBranchToCommonDest(): deal with mismatched IV's in PHI's in common successor block
This tries to approach the problem noted by @arsenm:
terrible codegen for `__builtin_fpclassify()`:
https://godbolt.org/z/388zqdE37

Just because the PHI in the common successor happens to have different
incoming values for these two blocks, doesn't mean we have to give up.
It's quite easy to deal with this, we just need to produce a select:
https://alive2.llvm.org/ce/z/000srb

Now, the cost model for this transform is rather overly strict,
so this will basically never fire. We tally all (over all preds)
the selects needed to the NumBonusInsts

Differential Revision: https://reviews.llvm.org/D139275
2022-12-12 18:20:03 +03:00
Zain Jaffal
ebae917294 Recommit "[AArch64] Select SMULL for zero extended vectors when top bit is zero"
This is a recommit of f9e0390751cb5eefbbbc191f851c52422acacab1
The previous commit failed to handle cases where the zero extended operand is an extended `BUILD_VECTOR`.
We don't replace zext with a sext operand to select smull if any operand is `BUILD_VECTOR`

Original commit message:

we can safely replace a `zext` instruction with `sext` if the top bit is zero. This is useful because we can select `smull` when both operands are sign extended.

Reviewed By: fhahn, dmgreen

Differential Revision: https://reviews.llvm.org/D134711
2022-12-12 14:45:54 +00:00
Zain Jaffal
dfc8ab2e25 Revert "Revert "[AArch64] Select SMULL for zero extended vectors when top bit is zero""
This reverts commit c07a01c2bb0d1f95689f809fd5be23829e364393.
2022-12-12 14:45:27 +00:00
David Green
c155fc8414 [AArch64][SVE] Add some hadd sve codegen tests. NFC 2022-12-12 14:35:01 +00:00
Chen Zheng
d7ee19d163 [PowerPC][GISel] add the missing verify option - NFC 2022-12-12 12:59:27 +00:00
Chen Zheng
b41d22db18 [PowerPC][GISel] support 32 bit load/store
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D135535
2022-12-12 12:52:44 +00:00
Chen Zheng
503a935d89 [PowerPC][GISel] support 64 bit load/store
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D134792
2022-12-12 12:20:54 +00:00
Nicholas Guy
0c51f9cd8f [NFC] Removal of complex deinterleaving i64 test cases
The tests in question are not particularly useful for testing complex
deinterleaving, especially due to i64 complex adds not being supported in mve.
The tests are being removed as they are hitting an unrelated pre-existing
condition regarding register spilling.
2022-12-12 12:02:00 +00:00
Nicholas Guy
a3dc5b534a [ARM][CodeGen] Add integer support for complex deinterleaving
Differential Revision: https://reviews.llvm.org/D139628
2022-12-12 11:38:19 +00:00
Peter Waller
8812b6eed7 [AArch64][SVE][Fixed length] Fix div miscompile
The prior code worked before SVE DIV was enabled 128 bit vectors.
With 128 bit vectors, when run on a 256 bit machine, it would split and
do a signed unpack, but this resulted in one full vector and one empty
vector with a half-sized predicate. The effect was that only half the
elements were treated correctly.

The fix is to bisect the vector, sign extend, do the division, truncate
and then concat.

Fixes #59357.

Differential Revision: https://reviews.llvm.org/D139618
2022-12-12 11:31:02 +00:00
Sameer Sahasrabuddhe
2fdeb27790 Revert "[AAPointerInfo] track multiple constant offsets for each use"
Assertion fired in openmp-offload-amdgpu-runtime:
https://lab.llvm.org/buildbot/#/builders/193/builds/23177

This reverts commit c2a0baad1fbb21fe111fef83ec93c2d7923b9b0c.
2022-12-12 15:39:18 +05:30
Nikita Popov
243acd5dcb [BasicAA] Remove support for PhiValues analysis
BasicAA currently has an optional dependency on the PhiValues
analysis. However, at least with our current pipeline setup, we
never actually make use of it. It's possible that this used to work
with the legacy pass manager, but I'm not sure of that either.

Given that this analysis has not actually been in use for a long
time, and nobody noticed or complained, I think we should drop
support for it and focus on one code path. It is worth noting that
analysis quality for the non-PhiValues case has significantly
improved in the meantime.

If we really wanted to make use of PhiValues, the right way would
probably be to pass it in via AAQI in places we want to use it,
rather than using an optional pass manager dependency (which are
an unpredictable PITA and should really only ever be used for
analyses that are only preserved and not used).

Differential Revision: https://reviews.llvm.org/D139719
2022-12-12 09:47:30 +01:00
David Green
fd716925ec [DAGCombine] Fold Splat(bitcast(buildvector(x,..))) to splat(x)
This adds a fold which teaches the backend to fold
splat(bitcast(buildvector(x,..))) or
splat(bitcast(scalar_to_vector(x))) to a single splat.

This only handles lane 0 splats, which are only valid under LE, and
needs to be a little careful with the types it creates for the new
buildvector.

Differential Revision: https://reviews.llvm.org/D139611
2022-12-12 08:35:43 +00:00
Sameer Sahasrabuddhe
c2a0baad1f [AAPointerInfo] track multiple constant offsets for each use
An expression of the form `gep(base, select(pred, const1, const2))` can result
in a set of offsets instead of just one. PointerInfo can now track these sets
instead of conservatively modeling them as Unknown. In general, AAPointerInfo
now uses AAPotentialConstantValues to examine the operands of the GEP.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D138646
2022-12-12 13:36:45 +05:30
jacquesguan
c2f199fa48 [DAGCombiner] Scalarize extend/truncate for splat vector.
This revision scalarizes extend/truncate for splat vector.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D122875
2022-12-12 14:53:10 +08:00
Craig Topper
f8c681227f [RISCV] Enable the Machine Late Cleanup pass.
Believe the bug has been fixed with D139169

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D139753
2022-12-11 20:55:05 -08:00
Zi Xuan Wu (Zeson)
62c4dce5b4 [CSKY][NFC] Fix check-all error due to change of expected output
- Remove unnecessary symbol offset check in MC cases.
- Change other expected output in CodeGen cases.
2022-12-12 11:30:52 +08:00
Yeting Kuo
47b9da72e0 [VP][RISCV] Add vp.bitreverse and RISC-V support.
The patch also added function expandVPBITREVERSE to expand ISD::VP_BITREVERSE nodes.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D139697
2022-12-12 10:58:44 +08:00
Xiang1 Zhang
9c88ccf9a9 [DAG] Stop combine for masked compressstore
Reviewed By: WangPengfei

Differential Revision: https://reviews.llvm.org/D139682
2022-12-12 10:40:20 +08:00
Roman Lebedev
7a2001509b
[StackProtector] Rewrite dominator tree update handling 2022-12-12 04:53:11 +03:00