49420 Commits

Author SHA1 Message Date
Patrick O'Neill
fcad2bbcfc [RISC-V] Add proposed mapping for Ztso
Currently LLVM emits Ztso code for fences, loads, and stores (behind an
experimental flag) [1]. This patch updates the mapping and implements
support for LR/SC and AMO ops. This updated mapping is compatible with
the RVWMO ABI present in the psABI. Additional context can be found in
the psABI pull request [2].

[1] https://reviews.llvm.org/D143076
[2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/391

Differential Revision: https://reviews.llvm.org/D155517
2023-08-10 15:59:06 +01:00
Philip Reames
0696a531c2 Revert "[DAG] Support store merging of vector constant stores"
This reverts commit 660b740e4b3c4b23dfba36940ae0fe2ad41bfedf.  Crash reported in the review thread post commit.  Reverting while investigating.
2023-08-10 07:58:00 -07:00
Nabeel Omer
d43634cd74 [X86] Pre-commit test for D157513
https://reviews.llvm.org/D157513
2023-08-10 15:40:12 +01:00
Luke Lau
b165a7779d [RISCV] Remove completed FIXME. NFC
Looks like this FIXME was already taken off during the original patch in
https://reviews.llvm.org/D104921
2023-08-10 15:31:05 +01:00
Sean Fertile
b37c7ed0c9 [PPC][AIX] Fix toc-data peephole bug and some related cleanup.
Set the ReplaceFlags variable to false, since there is code meant only
for the ADDItocHi/ADDItocL nodes. This has the side effect of disabling
the peephole when the load/store instruction has a non-zero offset.
This patch also fixes retrieving the `ImmOpnd` node from the AIX small
code model pseduos and does the same for the register operand node.
This allows cleaning up the later calls to replaceOperands.
Finally move calculating the MaxOffset into the code guarded by
ReplaceFlags as it is only used there and the comment is specific to the ELF
ABI.

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

Differential Revision: https://reviews.llvm.org/D155957
2023-08-10 10:23:15 -04:00
Jay Foad
3091bdb86d [AMDGPU] Do not release VGPRs at -O0
This was an oversight when the GFX11 early release VGPRs optimization
was reimplemented in D153279.

Sending the DEALLOC_VGPRS message is a performance optimization so there
is no need to do it at -O0. In addition it makes some kinds of post
mortem debugging hard or impossible, since VGPR values are no longer
available to inspect at the s_endpgm instruction.

Differential Revision: https://reviews.llvm.org/D157599
2023-08-10 14:58:06 +01:00
Simon Pilgrim
4ed452b747 [X86] getFauxShuffleMask - handle insert_subvector(src, bitcast(extract_subvector(sub))) patterns
Add bitcast handling to the existing insert_subvector(src, extract_subvector(sub)) pattern, and recognise undef src cases to allow us to detect vector widening patterns.
2023-08-10 13:38:38 +01:00
Paul Walker
3d65f8211f [SVE] Expand scalable vector ISD::BITCASTs when targeting big-endian.
Whilst sub-optimial, it's better than the current selection failure.

Fixes: #64406

Differential Revision: https://reviews.llvm.org/D157406
2023-08-10 11:02:01 +00:00
Jianjian GUAN
8901eb281f [RISCV] Fix zihintntl test 2023-08-10 17:18:17 +08:00
David Green
c26459258a [AArch64] Update check lines in neon-compare-instructions.ll
-global-isel-abort=2 is no longer required, and many of the tests can now
shared CHECK lines between SDAG and GlobalISel.
2023-08-10 10:09:13 +01:00
Jianjian GUAN
f808788487 [RISCV] Remove experimental for zihintntl
Since zihintntl is ratified now, we could remove the experimental prefix and change its version to 1.0.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D151547
2023-08-10 17:04:49 +08:00
Neumann Hon
3e139be29f [SystemZ][z/OS] Add support for function name field of PPA1
This PR causes the PPA1 to emit the function's name if it exists. This field is not emitted for unnamed functions.

Reviewed By: uweigand

Differential Revision: https://reviews.llvm.org/D157494
2023-08-10 04:40:19 -04:00
David Green
b720dcba92 [AArch64][GISel] Split large f64 vectors for fcmp.
This adds some very basic f64 handling for larger fcmp vectors, which seemed to
be missing.
2023-08-10 08:19:22 +01:00
Yunze Zhu
5f73d2b780 [RISCV] Enable alias analysis by default
In llvm alias analysis is off by default now.
This patch enable alias analysis on RISCV target during code generation by default,
and this makes more chances for improving performance.
Modified related test cases.

Differential Revision: https://reviews.llvm.org/D157250
2023-08-10 10:48:43 +08:00
Matt Arsenault
6dbd458128 AMDGPU: Remove pointless libcall optimization of fma/mad
After the library is linked and trivially inlined, the generic fma and
fmuladd intrinsics already handle these cases, and with precise flag
handling. This was requiring all fast math flags when we really just
need nsz for the fma(a, b, 0) case.

https://reviews.llvm.org/D156677
2023-08-09 19:37:52 -04:00
Matt Arsenault
6448d5ba58 AMDGPU: Remove pointless libcall recognition of native_{divide|recip}
This was trying to constant fold these calls, and also turn some of
them into a regular fmul/fdiv. There's no point to doing that, the
underlying library implementation should be using those in the first
place. Even when the library does use the rcp intrinsics, the backend
handles constant folding of those. This was also only performing the
folds under overly strict fast-evertyhing-is-required conditions.

The one possible plus this gained over linking in the library is if
you were using all fast math flags, it would propagate them to the new
instructions. We could address this in the library by adding more fast
math flags to the native implementations.

The constant fold case also had no test coverage.

https://reviews.llvm.org/D156676
2023-08-09 18:48:46 -04:00
Matt Arsenault
58e87c961e AMDGPU: Port AMDGPULowerKernelArguments to new pass manager
https://reviews.llvm.org/D157498
2023-08-09 18:34:30 -04:00
Matt Arsenault
1ca0808db2 GlobalISel: Don't expand stacksave/stackrestore in IRTranslator
In some (likely invalid edge cases anyway), it's not correct to
directly copy the stack pointer register.
2023-08-09 18:33:55 -04:00
Matt Arsenault
25bc999d1f Intrinsics: Add type overload to stacksave and stackstore
This allows use with non-0 address space stacks. llvm_ptr_ty should
never be used. This could use some more percolation up through mlir,
but this is enough to fix existing tests.

https://reviews.llvm.org/D156666
2023-08-09 18:33:11 -04:00
priyanshi1708
b16a0f9f6e [AArch64][Optimization]Emit FCCMP for AND of two float compares
Transforms and(fcmp(a, b), fcmp(c, d)) into fccmp(fcmp(a, b), c, d)
Issue link: https://github.com/llvm/llvm-project/issues/60819

Differential Revision: https://reviews.llvm.org/D152714
2023-08-09 15:58:04 +01:00
Paul Walker
b7e6e568b4 [SelectionDAG] Fix problematic call to EVT::changeVectorElementType().
The function changeVectorElementType assumes MVT input types will
result in MVT output types.  There's no gurantee this is possible
during early code generation and so this patch converts an instance
used during initial DAG construction to instead explicitly create a
new EVT.

NOTE: I could have added more MVTs, but that seemed unscalable as
you can either have MVTs with 100% element count coverage or 100%
bitwidth coverage, but not both.

Differential Revision: https://reviews.llvm.org/D157392
2023-08-09 12:50:02 +00:00
Matt Devereau
175850f987 [AArch64][SVE2] Combine trunc+add+lsr to rshrnb
The example sequence

  add z0.h, z0.h, #32
  lsr z0.h, #6
  st1b z0.h, x1

can be replaced with

  rshrnb z0.b, #6
  st1b z0.h, x1

As the top half of the destination elements are truncated.

In similar fashion,

  add z0.s, z0.s, #32
  lsr z1.s, z1.s, #6
  add z1.s, z1.s, #32
  lsr z0.s, z0.s, #6
  uzp1 z0.h, z0.h, z1.h

Can be replaced with

  rshrnb z1.h, z1.s, #6
  rshrnb z0.h, z0.s, #6
  uzp1 z0.h, z0.h, z1.h

Differential Revision: https://reviews.llvm.org/D155299
2023-08-09 12:49:42 +00:00
Quentin Colombet
bb206cb131 [NVPTX] Apply global var demotion to private symbols
When emitting the assembly we perform some late global variables demotion.
Prior to this patch, this optimization was only performed on variables with
the internal linkage whereas any local global variable can be demoted.

Fix that by using `hasLocalLinkage` instead of `hasInternalLinkage`.

Without this change, global variables with the `private` linkage wouldn't
be demoted.

Differential Revision: https://reviews.llvm.org/D154507
2023-08-09 14:41:01 +02:00
Sander de Smalen
ecb7b9c5c5 [Clang][AArch64] Diagnostics for SME attributes when target doesn't have 'sme'
This patch adds error diagnostics to Clang when code uses the AArch64 SME
attributes without specifying 'sme' as available target attribute.

* Function definitions marked as '__arm_streaming', '__arm_locally_streaming',
  '__arm_shared_za' or '__arm_new_za' will by definition use or require SME
  instructions.
* Calls from non-streaming functions to streaming-functions require
  the compiler to enable/disable streaming-SVE mode around the call-site.

In some cases we can accept the SME attributes without having 'sme' enabled:
* Function declaration can have the SME attributes.
* Definitions can be __arm_streaming_compatible since the generated
  code should execute on processing elements without SME.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D157269
2023-08-09 12:31:02 +00:00
pvanhout
c3cfbbc416 [GlobalISel] Add dead flags to implicit defs in ISel
Checks for implicit defs that are unused within a pattern and mark them as dead.

This is done directly at the TableGen level forr efficiency.
The instructions are directly created with the "dead" operand and no further analysis is needed later.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D157273
2023-08-09 14:20:51 +02:00
Simon Pilgrim
8ae0e1f58d [X86] Create X86ISD::SHUF128 512-bit masks with getV4X86ShuffleImm8ForMask
This allows us to use the same canonicalizations as PSHUFD/SHUFPS etc. to avoid unnecessary demanded elts (better splat detection, blend pass through etc.) instead of defaulting to zero mask values.
2023-08-09 11:13:03 +01:00
Alex Bradbury
89b8ebf3d6 [LegalizeTypes][RISCV] Correct FP_TO_{S,U}INT expansion when bf16 isn't a legal type
As noted in D156990, the logic in ExpandIntRes_FP_TO_SINT assumes that
if the type action for the float type is TypeSoftPromoteHalf, is must
have been an f16 (half). However, the meaning of that type action has
been overloaded and it is used for both f16 and bf16. This patch adds an
appropriate check to ensure ISD::FP16_TO_FP or ISD::BF16_TO_FP is
emitted as required.

Differential Revision: https://reviews.llvm.org/D157287
2023-08-09 11:01:28 +01:00
Igor Kirillov
60e2a849b0 [CodeGen] Disable FP LD1RX instructions generation for Neoverse-V1
These instructions show worse performance on Neoverse-V1 compared
to pair of LDR(LDP)/MOV instructions.
This patch adds `no-sve-fp-ld1r` sub-target feature, which is enabled
only on Neoverse-V1.

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

Differential Revision: https://reviews.llvm.org/D157279
2023-08-09 09:33:45 +00:00
Simon Wallis
33b9634394 [ARM] v6-M XO: save CPSR around LoadStackGuard
For Thumb-1 Execute-Only, expandLoadStackGuardBase generates a tMOVimm32 pseudo when calculating the stack offset.
It does this in a context where the CSPR maybe be live. tMOVimm32 may corrupt CPSR.
To fix this, generate save/restore CPSR around the tMOVimm32 using MRS/MSR to/from a scratch register.

expandLoadStackGuardBase this runs after register allocation, so the scratch register needs to be a physical register.
Use R12 as a scratch register, as is usual when expanding a pseudo.
MSR/MRS are some of the few v6-M instructions which operate on a high register.

New stack-guard test case added which was generating incorrect code without the save/restore CPSR.

Reviewed By: stuij

Differential Revision: https://reviews.llvm.org/D156968
2023-08-09 08:40:35 +01:00
Konstantina Mitropoulou
2c5d1b5ab7 [DAGCombiner] Reassociate the operands from (OR (OR(CMP1, CMP2)), CMP3) to (OR (OR(CMP1, CMP3)), CMP2)
This happens when CMP1 and CMP3 have the same predicate (or CMP2 and CMP3 have
the same predicate).

This helps optimizations such as the fololowing one:
CMP(A,C)||CMP(B,C) => CMP(MIN/MAX(A,B), C)
CMP(A,C)&&CMP(B,C) => CMP(MIN/MAX(A,B), C)

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D156215
2023-08-08 20:08:01 -07:00
Konstantina Mitropoulou
51202b8d2e [NFC][DAGCombiner] Tests for future commit.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D155915
2023-08-08 20:05:23 -07:00
Weining Lu
f62c9252fc [LoongArch] Support -march=native and -mtune=
As described in [1][2], `-mtune=` is used to select the type of target
microarchitecture, defaults to the value of `-march`. The set of
possible values should be a superset of `-march` values. Currently
possible values of `-march=` and `-mtune=` are `native`, `loongarch64`
and `la464`.

D136146 has supported `-march={loongarch64,la464}` and this patch adds
support for `-march=native` and `-mtune=`.

A new ProcessorModel called `loongarch64` is defined in LoongArch.td
to support `-mtune=loongarch64`.

`llvm::sys::getHostCPUName()` returns `generic` on unknown or future
LoongArch CPUs, e.g. the not yet added `la664`, leading to
`llvm::LoongArch::isValidArchName()` failing to parse the arch name.
In this case, use `loongarch64` as the default arch name for 64-bit
CPUs.

Two preprocessor macros are defined based on user-provided `-march=`
and `-mtune=` options and the defaults.
- __loongarch_arch
- __loongarch_tune
Note that, to work with `-fno-integrated-cc1` we leverage cc1 options
`-target-cpu` and `-tune-cpu` to pass driver options `-march=` and
`-mtune=` respectively because cc1 needs these information to define
macros in `LoongArchTargetInfo::getTargetDefines`.

[1]: https://github.com/loongson/LoongArch-Documentation/blob/2023.04.20/docs/LoongArch-toolchain-conventions-EN.adoc
[2]: https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc

Reviewed By: xen0n, wangleiat, steven_wu, MaskRay

Differential Revision: https://reviews.llvm.org/D155824
2023-08-09 10:29:50 +08:00
David Green
c782e3497d [AArch64] Add VSHL knownBits handling.
These can be handled in the same way as other shifts.
2023-08-08 21:59:53 +01:00
David Green
2bb727297d [AArch64] Regenerate s/urem-seteq-* tests. NFC 2023-08-08 21:34:34 +01:00
Matt Arsenault
87b6f85c2b AMDGPU: Add syncscopes to some atomic tests
These were not testing what was intended, which should be the cases we
can directly select to the instructions.
2023-08-08 14:38:06 -04:00
Matt Arsenault
3371849194 AMDGPU: Round out system atomics tests
There were system scope tests only for integer min/max. Expand this to
cover all of the integer operations.
2023-08-08 14:38:05 -04:00
Matt Arsenault
7db933a716 AMDGPU: Fix broken test checks
There were incomplete generated checks plus some dead manual checks.
2023-08-08 14:38:05 -04:00
Simon Pilgrim
7593f9b59a [X86] combineConcatVectorOps - add handling for X86ISD::SHUF128 nodes.
Prevents regression on some future work to improve codegen for concat_vectors(extract_subvector(),extract_subvector()) patterns.

X86ISD::SHUF128 optimization is still pretty poor (especially the zmm variant), not optimizing the shuffle demanded elts like we do for SHUFPS.
2023-08-08 18:13:43 +01:00
Igor Kirillov
84d444f909 [CodeGen] Fix incorrect pattern FMLA_* pseudo instructions
* Remove the incorrect patterns from AArch64fmla_p/AArch64fmls_p
* Add correct patterns to AArch64fmla_m1/AArch64fmls_m1
* Refactor fma_patfrags for the sake of PatFrags

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

Differential Revision: https://reviews.llvm.org/D157095
2023-08-08 16:34:31 +00:00
pvanhout
96e1032a5e [AMDGPU] Add extended-image-insts to RemoveIncompatibleFunctions
Otherwise device libs still has issues at O0 (in OpenCL-CTS)

Depends on D156972 as well. They're unrelated fixes but both are needed to fix the issue.

Fixes SWDEV-402331

Reviewed By: #amdgpu, arsenm

Differential Revision: https://reviews.llvm.org/D156973
2023-08-08 15:15:57 +02:00
pvanhout
98ccc70b93 [DAG] Fix crash in replaceStoreOfInsertLoad
Idx's type can be different from Ptr's, causing a "Binary operator types must match" assertion failure when emitting the MUL.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D156972
2023-08-08 15:15:34 +02:00
Alex Bradbury
f7dbc8501f [LegalizeTypes][RISCV] Support libcalls for fpto{s,u}i of bfloat by extending to f32 first
As there is no direct bf16 libcall for these conversions, extend to f32
first.

This patch includes a tiny refactoring to pull out equivalent logic in
ExpandIntRes_XROUND_XRINT so it can be reused in
ExpandIntRes_FP_TO_{S,U}INT.

This patch also demonstrates incorrect codegen for RV32 without zfbfmin
for the newly enabled tests. As it doesn't introduce that incorrect
codegen (caused by the assumption that 'TypeSoftPromoteHalf' is only
used for f16 types), a fix will be added in a follow-up (D157287).

Differential Revision: https://reviews.llvm.org/D156990
2023-08-08 13:56:32 +01:00
Jolanta Jensen
932972305b [NFC][AArch64] Added checks for global entries in ReplaceWithVeclib testing
This patch added checks for global entries in ReplaceWithVeclib testing
using ArmPL and SLEEF vector libraries.

Differential Revision: https://reviews.llvm.org/D157258
2023-08-08 12:28:58 +00:00
Matt Devereau
e8efe7f9d1 [AArch64][SME2][SVE2p1] Choose strided or contiguous loads
Lower to the strided/contiguous addressing mode of
ld1/ldnt1 instructions depending on register allocation.

Differential Revision: https://reviews.llvm.org/D156311
2023-08-08 11:50:33 +00:00
Igor Kirillov
7542477d5d [CodeGen] Precommit tests for D157095 2023-08-08 11:38:15 +00:00
Igor Kirillov
b560d5c7e3 [CodeGen] Pre-commit tests showing incorrect pattern FMLA_* pseudo instructions
Differential Revision: https://reviews.llvm.org/D157094
2023-08-08 10:52:55 +00:00
David Green
de775f264d [DAG] Add constant SPLAT handling in getNodes SIGN_EXTEND_INREG
This helps simplify constant splats a little. Without this the code in
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L14072 always returns the
existing node.

Differential Revision: https://reviews.llvm.org/D157259
2023-08-08 10:27:55 +01:00
Simon Pilgrim
943fda567a [X86] matchTruncateWithPACK - canonically prefer v4i64 -> v4i32 shuffle vs truncation
Pulled out of LowerTruncateVecPackWithSignBits - prefer shuffles unless we can cheaply split the vector. ComputeNumSignBits struggles with vXi64 through bitcasts, so we're usually better off with shuffles.
2023-08-08 10:05:24 +01:00
Luke Lau
5d510ea724 [RISCV] Lower vro{l,r} for fixed vectors
We need to add new VL nodes to mirror ISD::ROTL and ISD::ROTR.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D157295
2023-08-08 09:47:00 +01:00
Luke Lau
768740ef77 [RISCV] Lower unary zvbb ops for fixed vectors
This reuses the same strategy for fixed vectors as other ops, i.e. custom lower
to a scalable *_vl SD node.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D157294
2023-08-08 09:46:57 +01:00