72591 Commits

Author SHA1 Message Date
Craig Topper
4f5f38bdab [RISCV] Add early out to generateInstSeq when the initial sequence is 1 or 2 instructions.
This avoids checking the size of the sequence repeatedly for each
special case. Especially on RV32 where none of the special cases
apply.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D152300
2023-06-06 13:23:17 -07:00
David Green
2a8df8d0b9 [AArch64][SVE] Add one-use-check to EitherVSelectOrPassthruPatFrags
As pointed out in D149968 vselect predicate patterns could do with a one-use
check to prevent multiple operations being created. This updates the
EitherVSelectOrPassthruPatFrags pattern frags used in creating predicates
min/max.

Differential Revision: https://reviews.llvm.org/D151080
2023-06-06 21:10:32 +01:00
Stanislav Mekhanoshin
febcf99e9d [AMDGPU] Replace std::pair with VOPDCombineInfo in VOPD combine. NFC.
The future patch will carry additional info there.

Differential Revision: https://reviews.llvm.org/D152302
2023-06-06 12:53:23 -07:00
Jessica Clarke
db1d72b155 [RISCV] Don't persist invalid feature state on .option arch error
Otherwise subsequent .option arch, +foo directives (but not -, since
those have their own separate validation) fail the parseFeatureBits
check, leading to cascading errors.

Reviewed By: luismarques, MaskRay

Differential Revision: https://reviews.llvm.org/D152273
2023-06-06 20:15:12 +01:00
Craig Topper
58b2d652af [RISCV] Add special case to selectImm for constants that can be created with (ADD (SLLI C, 32), C).
Where C is a simm32.

This costs an extra temporary register, but avoids a constant pool.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D152236
2023-06-06 11:59:12 -07:00
Simon Pilgrim
a279a09ab9 Revert rG98061013e01207444cfd3980 - [X86] X86FixupVectorConstantsPass - attempt to replace full width fp vector constant loads with broadcasts on AVX+ targets
Reverting while we address an existing issue exposed by this (Issue #63108)
2023-06-06 18:44:24 +01:00
Craig Topper
45680acbbe [RISCV] Remove uses of RISCVII::hasMergeOp from RISCVDAGToDAGISel.cpp
This property was intended to indicate when RISCVAsmPrinter should
drop the tied source operand when converting to MCInst. Using it
in RISCVDAGToDAGISel distorts what it intended for.

This should remove some changes from D151850.

Reviewed By: frasercrmck, asb

Differential Revision: https://reviews.llvm.org/D152039
2023-06-06 10:19:52 -07:00
Simon Pilgrim
78de45fd4a Revert rGab4b924832ce26c21b88d7f82fcf4992ea8906bb - [X86] X86FixupVectorConstantsPass - attempt to replace full width integer vector constant loads with broadcasts on AVX2+ targets
Reverting while we address an existing issue exposed by this (Issue #63108)
2023-06-06 18:07:33 +01:00
prabhukr
30198bd788 [Triple] Add triple for UEFI
Target triple to support "x86_64-unknown-uefi"

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D131594
2023-06-06 08:42:28 -07:00
Jolanta Jensen
a963dbb5ac [SVE ACLE] Extend existing aarch64_sve_mul combines to also act on aarch64_sve_mul_u.
Differential Revision: https://reviews.llvm.org/D152004
2023-06-06 15:26:33 +00:00
Jessica Clarke
06e253c10d [RISCV] Rework .option arch target streamer interface
The current interface requires some rather ugly tracking of state due to
splitting up the calls for each argument. Instead, pack them all into a
single call by passing an ArrayRef. Also clean up the dodgy whitespace
emitted for the directive whilst here; there was a stray space between
the tab and .option, and there was a tab rather than a space after the
first comma for some strange reason.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152193
2023-06-06 14:56:20 +01:00
Jessica Clarke
2c11768eee [RISCV] Make .option arch parser less mind-bending
Currently the early-return flow in the infinite loop makes it hard to
find the non-error termination points amongst the sea of errors. Rewrite
it with a more conventional control flow that has a clear loop guard (in
place of one of the early returns) and a break (in place of the other),
and with greater code reuse.

This has a small effect on the errors given for malformed input, as seen
in the affected test, and is probably more helpful as a result. Note
that we also bail early now if parseComma fails, as is standard.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152192
2023-06-06 14:56:20 +01:00
Simon Pilgrim
c6f5f6ab61 [GlobalISel][X86] Move G_SEXT_INREG legalization handling to beside the regular integer extension legalizations 2023-06-06 14:39:10 +01:00
Jay Foad
304538ae7b [GlobalIsel][X86] Remove an unused variable 2023-06-06 14:10:14 +01:00
Jay Foad
a4a3ac10cb [AMDGPU] Remove extract_subvector patterns
Removing them seems to slightly increase code quality as well as
simplifying both the tablegen and C++ parts of the code.

Differential Revision: https://reviews.llvm.org/D149853
2023-06-06 14:04:50 +01:00
Ricardo Jesus
3a87c15026 [AArch64][NFC] Normalise name of indexed forms of SQRDMLAH/SQRDMLSH
Most indexed vector instructions are suffixed with v<N><TY>_indexed.

SQRDMLAH/SQRDMLSH are the exception, being suffixed with <TY>_indexed
instead, which can complicate matching them slightly.

Differential Revision: https://reviews.llvm.org/D152161
2023-06-06 13:02:36 +00:00
Simon Pilgrim
ee1d6132e7 [GlobalIsel][X86] Update legalization of G_FADD/G_FSUB/G_FMUL/G_FDIV + G_FC
Replace the legacy legalizer versions
2023-06-06 13:47:34 +01:00
David Stuttard
b2817d22bb Revert "[AMDGPU] New PAL metadata updates to ps_extra_lds_size and float_mode"
This reverts commit 6d5a653dda628250b373ec89e0e11cdd27603c24.
2023-06-06 13:02:28 +01:00
David Stuttard
6d5a653dda [AMDGPU] New PAL metadata updates to ps_extra_lds_size and float_mode
New metadata format contains full calculation of field contents for
ps_extra_lds_size (vs old format where the value in RSRC register is used by PAL
to calculate the value required).

Also stop updating float_mode and rely on front end settings for this field.

Differential Revision: https://reviews.llvm.org/D152247
2023-06-06 12:18:21 +01:00
Simon Pilgrim
85b77b13e3 [GlobalISel][X86] Add G_IMPLICIT_DEF / G_CONSTANT legalization handling 2023-06-06 11:45:22 +01:00
Thorsten Schütt
60b8019ea0 [GlobalIsel][X86] Legalize G_ANYEXT, G_SEXT, and G_ZEXT
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D152243
2023-06-06 12:22:09 +02:00
wangpc
26e41a80d0 [RISCV] Handle "o" inline asm memory constraint
This is the same as D100412.

We just found the same crash when we tried to compile some packages
like mariadb, php, etc.

For constraint "o", it means "A memory operand is allowed, but
only if the address is offsettable". So I think it can be handled
just like constraint "m" for RISCV target.

And we print verbose information when unsupported constraints occur.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D151979
2023-06-06 17:50:40 +08:00
Carl Ritson
6afc4b0629 [AMDGPU] WQM: Ensure exact mode placement before branches
Fix for D151797 where the change accidentally allowed exit to
exact mode between branch instructions.

Reviewed By: dstuttard

Differential Revision: https://reviews.llvm.org/D152228
2023-06-06 18:11:35 +09:00
Martin Storsjö
a499d675ae [AArch64] Make .arch without extra features actually take effect
This fixes PR32873 / https://github.com/llvm/llvm-project/issues/32220.

Differential Revision: https://reviews.llvm.org/D151982
2023-06-06 11:50:04 +03:00
Martin Storsjö
4b8d9abca7 [AArch64] Complete the list of extensions supported by .arch and .arch_extension
This brings the list of extensions supported here up to date
with what is supported by current git versions of binutils.

Also add a comment to AArch64TargetParser to remind people to
consider adding new ones to the list supported in assembly.

In the case of the "rdma" extension, there's a slight surprise:
LLVM knows of the extension under the name "rdm", while binutils
has it named "rdma". However, binutils appears to accept any
abbreviated prefix of an arch extension, so it does accept the
form "rdm" too even if it formally considers it called "rdma".

Support both spellings for the extensions here, for simplicity.

Differential Revision: https://reviews.llvm.org/D151981
2023-06-06 11:50:03 +03:00
Craig Topper
03bc33c809 Revert "[RISCV] Minor readability improvement to RISCVMatInt. NFC"
This reverts commit 1ebe06017df607d4fc140f6b166e35cd32fc5f16.

I've been informed the old way was documented in the psABI.
2023-06-05 23:22:28 -07:00
Craig Topper
1ebe06017d [RISCV] Minor readability improvement to RISCVMatInt. NFC
When splitting a simm32 into LUI+ADDI(W). Subtract Lo12 from Val
to calculate Hi20. This replaces the old method of adding 0x800 to
Val. This change makes the math the reverse of how the LUI+ADDI(W)
create the immediate.
2023-06-05 23:07:35 -07:00
Fangrui Song
993a923a09 [RISCV] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
Similar to AArch64,AVR,PowerPC: 9e2d100e5322c52e29280c96bbb5609ca5af1539.
2023-06-05 21:40:32 -07:00
Fangrui Song
9e2d100e53 [AArch64,AVR,PowerPC] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
Similar to 49488490d195591bfc90daef111cd7293f8c80aa.
2023-06-05 21:33:10 -07:00
Phoebe Wang
6e488e40e7 Reland "[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle" 2023-06-06 10:49:25 +08:00
Phoebe Wang
4ac501c5ca Revert "[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle"
This reverts commit 50a2341fe92f8a5ff934bd279450581e9cbcf103.

This results in buildbot fail.
2023-06-06 10:41:26 +08:00
Phoebe Wang
50a2341fe9 [X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle 2023-06-06 10:27:09 +08:00
Jianjian GUAN
77da27b5e3 [RISCV] Improve selection for vector fpclass.
Since vfclass intruction will only set one single bit in the result, so if we only want to check 1 fp class, we could use vmseq to do it.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D151967
2023-06-06 10:24:24 +08:00
NAKAMURA Takumi
ebb02fb275 RISCVISelLowering.cpp: Suppress a warning. (D150824) 2023-06-06 08:55:46 +09:00
Matt Arsenault
b25c001ad3 AMDGPU: Fold zext into result of v_mad_u16 on high zeroing targets
Avoids regressions in future patch.
2023-06-05 18:41:07 -04:00
Craig Topper
b64ddae8a2 [RISCV] Lower experimental_get_vector_length intrinsic to vsetvli for some cases.
This patch lowers to vsetvli when the AVL is i32 or XLenVT and
the VF is a power of 2 in the range [1, 64]. VLEN=32 is not supported
as we don't have a valid type mapping for that. VF=1 is not supported
with Zve32* only.

The element width is used to set the SEW for the vsetvli if possible.
Otherwise we use SEW=8.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D150824
2023-06-05 15:02:11 -07:00
Craig Topper
4157bfb230 [RISCV] Add RISCVISD nodes for vfwadd/vfwsub.
Add a DAG combine to form these from FADD_VL/FSUB_VL and FP_EXTEND_VL.

This makes it similar to other widening ops and allows us to handle
using the same FP_EXTEND_VL for both operands.

Differential Revision: https://reviews.llvm.org/D151969
2023-06-05 14:12:47 -07:00
Craig Topper
c4224782cd [RISCV] Rename SDT_RISCVVWBinOpW_VL->SDT_RISCVVWIntBinOpW_VL. NFC
Preparation for D151969 which adds an FP version.
2023-06-05 14:12:47 -07:00
Artem Belevich
dc90f42ea7 Coalesce 16-bit FP types to use integer register classes.
i16/f16/bf16 will use the same .b16 registers and
i32/v2f16 and v2bf16 will share .b32 registers.

The changes are mostly mechanical, intended to remove unnecessary register
classes which tend to produce redundant register moves.

Differential Revision: https://reviews.llvm.org/D151601

v2f16 regtype conversion to i32
2023-06-05 12:21:52 -07:00
Krzysztof Drewniak
23098bd454 [AMDGPU] Add intrinsic for converting global pointers to resources
Define the function @llvm.amdgcn.make.buffer.rsrc, which take a 64-bit
pointer, the 16-bit stride/swizzling constant that replace the high 16
bits of an address in a buffer resource, the 32-bit extent/number of
elements, and the 32-bit flags (the latter two being the 3rd and 4th
wards of the resource), and combines them into a ptr addrspace(8).

This intrinsic is lowered during the early phases of the backend.

This intrinsic is needed so that alias analysis can correctly infer
that a certain buffer resource points to the same memory as some
global pointer. Previous methods of constructing buffer resources,
which relied on ptrtoint, would not allow for such an inference.

Depends on D148184

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D148957
2023-06-05 17:07:59 +00:00
Krzysztof Drewniak
ab37937812 [AMDGPU] Use resource base for buffer instruction MachineMemOperands
1. Remove the existing code that would encode the constant offsets (if
there were any) on buffer intrinsic operations onto their
`MachineMemOperand`s. As far as I can tell, this use of `offset` has
no substantial impact on the generated code, especially since the same
reasoning is performed by areMemAccessesTriviallyDisjoint().

2. When a buffer resource intrinsic takes a pointer argument as the
base resource/descriptor, place that memory argument in the value
field of the MachineMemOperand attached to that intrinsic.

This is more conservative than what would be produced by more typical
LLVM code using GEP, as the Value (for alias analysis purposes)
corresponding to accessing buffer[0] and buffer[1] is the same.
However, the target-specific analysis of disjoint offsets covers a lot
of the simple usecases.

Despite this limitation, the new buffer intrinsics, combined with
LLVM's existing pointer annotations, allow for non-trivial
optimizations, as seen in the new tests, where marking two buffer
descriptors "noalias" allows merging together loads and stores in a
"load from A, modify loaded value, store to B" sequence, which would
not be possible previously.

Depends on D147547

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D148184
2023-06-05 17:06:57 +00:00
Krzysztof Drewniak
faa2c678aa [AMDGPU] Add buffer intrinsics that take resources as pointers
In order to enable the LLVM frontend to better analyze buffer
operations (and to potentially enable more precise analyses on the
backend), define versions of the raw and structured buffer intrinsics
that use `ptr addrspace(8)` instead of `<4 x i32>` to represent their
rsrc arguments.

The new intrinsics are named by replacing `buffer.` with `buffer.ptr`.

One advantage to these intrinsic definitions is that, instead of
specifying that a buffer load/store will read/write some memory, we
can indicate that the memory read or written will be based on the
pointer argument. This means that, for example, a read from a
`noalias` buffer can be pulled out of a loop that is modifying a
distinct buffer.

In the future, we will define custom PseudoSourceValues that will
allow us to package up the (buffer, index, offset) triples that buffer
intrinsics contain and allow for more precise backend analysis.

This work also enables creating address space 7, which represents
manipulation of raw buffers using native LLVM load and store
instructions.

Where tests simply used a buffer intrinsic while testing some other
code path (such as the tests for VGPR spills), they have been updated
to use the new intrinsic form. Tests that are "about" buffer
intrinsics (for instance, those that ensure that they codegen as
expected) have been duplicated, either within existing files or into
new ones.

Depends on D145441

Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D147547
2023-06-05 16:59:07 +00:00
Craig Topper
7a2b12b05b [RISCV] Switch vwsll.v* instructions to use the VSHT_IV_V_X_I class instead of VALU_IV_V_X_I.
This allows us to remove the uimm5 argument and changes the
scheduler class from ALU to Shift.

Ultimately we need a WShift scheduler class, but we need to scrub
all of the crypto instructions for scheduler classes so I'll leave
that for future work.

Reviewed By: 4vtomat, ego

Differential Revision: https://reviews.llvm.org/D152030
2023-06-05 09:24:50 -07:00
Ivan Kosarev
48570678c1 [AMDGPU][AsmParser][NFC] Specify parser methods directly in operand classes.
Eliminates the need for custom operand classes whose only purpose is to
define a parser method.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: dp

Differential Revision: https://reviews.llvm.org/D151685
2023-06-05 13:04:15 +01:00
Ivan Kosarev
9ad1a48ad7 [AMDGPU][AsmParser][NFC] Immediate operand classes to derive from custom operands.
Removes unnecessary duplication in TableGen definitions.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: dp

Differential Revision: https://reviews.llvm.org/D151684
2023-06-05 12:40:44 +01:00
Mateja Marjanovic
c91246b71e fix failures caused by https://reviews.llvm.org/D146737
buildbot: https://lab.llvm.org/buildbot/#/builders/77/builds/27340
2023-06-05 13:10:27 +02:00
Mateja Marjanovic
88421ea973 [AMDGPU] Trim zero components from buffer and image stores
For image and buffer stores the default behaviour on GFX11 and
older is to set all unset components to zero. So if we pass
only X component it will be the same as X000, or XY same as XY00.

This patch simplifies the passed vector of components in InstCombine
by removing zero components from the end.

For image stores it also trims DMask if necessary.

Reviewed by: arsenm, foad, nhaehnle, piotr
2023-06-05 12:30:21 +02:00
Simon Pilgrim
d37bd544ff [X86] canonicalizeShuffleWithBinOps - ensure a binary shuffle of binops have the same value type
Fixes #63091
2023-06-05 11:18:28 +01:00
Simon Pilgrim
346ee549e5 [GlobalISel][X86] Add G_CTTZ_ZERO_UNDEF/G_CTTZ legalization handling
G_CTTZ_ZERO_UNDEF is always legal using the BSF instruction, G_CTTZ requires the BMI1 TZCNT instruction
2023-06-05 11:18:27 +01:00
Jay Foad
3030c03988 [AMDGPU] Make use of MachineInstr::all_defs and all_uses. NFCI. 2023-06-05 10:32:33 +01:00