57019 Commits

Author SHA1 Message Date
David Stuttard
ebc5020564
[AMDGPU] Update entry point name for PAL metadata (#123581)
Old entry-point metadata being updated. Nothing is required
to account for deprecation as nothing uses the old style
2025-01-21 09:37:22 +00:00
David Green
547bfda56b
[AArch64] Improve bcvtn2 and remove aarch64_neon_bfcvt intrinsics (#120363)
This started out as trying to combine bf16 fpround to BFCVT2
instructions, but ended up removing the aarch64.neon.nfcvt intrinsics in
favour of generating fpround instructions directly. This simplifies the
patterns and can lead to other optimizations. The BFCVT2 instruction is
adjusted to makes sure the types are valid, and a bfcvt2 is now
generated in more place. The old intrinsics are auto-upgraded to fptrunc
instructions too.
2025-01-21 09:16:04 +00:00
Marius Kamp
c22364a432
[AArch64] Eliminate Common SUBS by Reassociating Non-Constants (#123344)
Commit 1eed46960c217f9480865702f06fb730c7521e61 added logic to
reassociate a (add (add x y) -c) operand to a CSEL instruction with a
comparison involving x and c (or a similar constant) in order to obtain
a common (SUBS x c) instruction.
    
This commit extends this logic to non-constants. In this way, we also
reassociate a (sub (add x y) z) operand of a CSEL instruction to
(add (sub x z) y) if the CSEL compares x and z, for example.
    
Alive proof: https://alive2.llvm.org/ce/z/SEVpR
2025-01-21 09:15:02 +00:00
Hervé Poussineau
26b87aad9e
[Mips] Handle declspec(dllimport) on mipsel-windows-* triples (#120912)
On Windows, imported symbols must be searched with '__imp_' prefix.
Support imported global variables and imported functions.
2025-01-21 16:18:02 +08:00
Cinhi Young
385f776b63
[MIPS][MSA] Invert operand order of ILVOD when lowering VECTOR_SHUFFLE (#123555)
This PR fixes operand order of `ILVOD.df` when lowering
`VECTOR_SHUFFLE`, the result was `<y[1], x[1]>` while it should be
`<x[1], y[1]>`.

* This PR is split from #123040.
2025-01-21 15:54:10 +08:00
Matt Arsenault
585858aeb6 AMDGPU: Fix asm constrains in new shuffle tests
These passed prechecks but failed after cc5eba1737146a727a61b5dbe16d8c2ac453981e
2025-01-21 10:49:42 +07:00
Matt Arsenault
7786266dc7
AMDGPU: Expand shuffle testing with generated tests (#123574)
Add some generated tests with every shuffle permutation
for relevant vector element types and sizes. Not sure if this
is going overboard with the number of tests. I pruned out the largest
cases (16 and 32-bit cases are impractically large), and there's
redundancy when testing the pointer cases (at least for SelectionDAG).

This uses inline assembly to produce sample values because of how the
ABI is lowered when using a function argument. Since we break all
arguments into 32-bit pieces, a shuffle never ends up forming. We
need separate handling to reconstruct shuffles in contexts involving
physical registers in ABI contexts.

I wrote a small tool to generate these, so I can easily change the
exact test body. Not sure if it's worth posting anywhere.

This is in preparation for making better use of v_pk_mov_b32,
v_mov_b64 and s_mov_b64 in shuffles.
2025-01-21 10:08:42 +07:00
Feng Zou
abbfed9be7
[X86][AMX] Fix handling of AMX-FP8 internal intrinsics (#123540)
This is to fix #123410.
2025-01-21 10:11:29 +08:00
Justin Bogner
b6287fd971
[DirectX] Set the EnableRawAndStructuredBuffers shader flag (#122667)
When raw or structured buffers are used, we need to set the DXIL flag
saying so.

Fixes #122663.
2025-01-20 17:05:34 -07:00
Krzysztof Drewniak
697c1883f1
Reapply "[AMDGPU] Handle natively unsupported types in addrspace(7) lowering" (#123660)
(#123657)

This reverts commit 64749fb01538fba2b56d9850497d5f3a626cabc2.

Adds a constructor to VecSlice to address the failure
2025-01-20 16:12:17 -06:00
Ulrich Weigand
8424bf207e [SystemZ] Add support for new cpu architecture - arch15
This patch adds support for the next-generation arch15
CPU architecture to the SystemZ backend.

This includes:
- Basic support for the new processor and its features.
- Detection of arch15 as host processor.
- Assembler/disassembler support for new instructions.
- Exploitation of new instructions for code generation.
- New vector (signed|unsigned|bool) __int128 data types.
- New LLVM intrinsics for certain new instructions.
- Support for low-level builtins mapped to new LLVM intrinsics.
- New high-level intrinsics in vecintrin.h.
- Indicate support by defining  __VEC__ == 10305.

Note: No currently available Z system supports the arch15
architecture.  Once new systems become available, the
official system name will be added as supported -march name.
2025-01-20 19:30:21 +01:00
Krzysztof Drewniak
64749fb015
Revert "[AMDGPU] Handle natively unsupported types in addrspace(7) lowering" (#123657)
Reverts llvm/llvm-project#110572

Seem to have broken a buildbot, not sure why
https://lab.llvm.org/buildbot/#/builders/108/builds/8346
2025-01-20 13:14:04 -05:00
Krzysztof Drewniak
3805355ef6
[AMDGPU] Handle natively unsupported types in addrspace(7) lowering (#110572)
The current lowering for ptr addrspace(7) assumed that the instruction
selector can handle arbtrary LLVM types, which is not the case. Code
generation can't deal with
- Values that aren't 8, 16, 32, 64, 96, or 128 bits long
- Aggregates (this commit only handles arrays of scalars, more may come)
- Vectors of more than one byte
- 3-word values that aren't a vector of 3 32-bit values (for axample, a
<6 x half>)

This commit adds a buffer contents type legalizer that adds the needed
bitcasts, zero-extensions, and splits into subcompnents needed to
convert a load or store operation into one that can be successfully
lowered through code generation.

In the long run, some of the involved bitcasts (though potentially not
the buffer operation splitting) ought to be handled by the instruction
legalizer, but SelectionDAG makes this difficult.

It also takes advantage of the new `nuw` flag on `getelementptr` when
lowering GEPs to offset additions.

We don't currently plumb through `nsw` on GEPs since that should likely
be a separate change and would require declaring what we mean by "the
address" in the context of the GEP guarantees.
2025-01-20 11:33:35 -06:00
Alex MacLean
3606876b67
[SDAG] Fix CSE for ADDRSPACECAST nodes (#122912)
Correct CSE in SelectionDAG can make DAG combining more effective and
reduces the size of the DAG and thus should improve compile time.
2025-01-20 09:09:22 -08:00
Fabian Ritter
cc5eba1737
[AMDGPU] Reject misaligned SGPR constraints for inline asm (#123590)
The indices of SGPR register pairs need to be 2-aligned and SGPR
quadruplets need to be 4-aligned. With this patch, we report an error
when inline asm register constraints specify a misaligned register
index, instead of silently dropping the specified index.

Fixes #123208

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-01-20 15:47:11 +01:00
Fraser Cormack
9cf24652e7
[AMDGPU] Fix spurious NoAlias results (#122309)
After a30e50fc, AMDGPUAAResult is being called in more situations where
BasicAA isn't sure. This exposed some regressions where NoAlias is being
incorrectly returned for two identical pointers.

The fix is to check the underlying objects for equality before returning
NoAlias.
2025-01-20 14:19:30 +00:00
Graham Hunter
d9f165ddea
[SDAG] Add an ISD node to help lower vector.extract.last.active (#118810)
Based on feedback from the clastb codegen PR, I'm refactoring basic codegen for the vector.extract.last.active intrinsic to lower to an ISD node in SelectionDAGBuilder then expand in LegalizeVectorOps, instead of doing everything in the builder.

The new ISD node (vector_find_last_active) only covers finding the index of the last active element of the mask, and extracting the element + handling passthru is left to existing ISD nodes.
2025-01-20 12:57:05 +00:00
Akshat Oke
96c4f978d0
[AMDGPU][NewPM] Port SIOptimizeExecMasking to NPM (#123572) 2025-01-20 16:34:01 +05:30
yingopq
754ed95b66
[Mips] Fix compiler crash when returning fp128 after calling a functi… (#117525)
…on returning { i8, i128 }

Fixes https://github.com/llvm/llvm-project/issues/96432.
2025-01-20 16:47:40 +08:00
ZhaoQi
84220eccb6
[LoongArch] Add generation support for preld instruction (#118436)
Instruction `preld` is used to prefetch one cache-line of data from
memory in advance into the cache.

This commit allows it to be generated automatically.
2025-01-20 16:11:09 +08:00
ZhaoQi
0288d065ee
[LoongArch] Avoid scheduling relaxable code sequence and attach relax relocs (#121330)
If linker relaxation enabled, relaxable code sequence expanded from
pseudos should avoid being separated by instruction scheduling. This
commit tags scheduling boundary for them to avoid being scheduled.
(Except for `tls_le/tls_ie` and `call36/tail36`. Because `tls_le/tls_ie`
can be scheduled and have no influence to relax, `call36/tail36` are
expanded later in `LoongArchExpandPseudo` pass.)

A new mask target-flag is added to attach relax relocs to the relaxable
code sequence. (No need to add it for `tls_le` and `call36/tail36`
because we can simply add relax relocs for them according to their
relocs. But for other code sequence, such as `PCALA_{HI20/LO12}`, we
must use the mask flag, mainly because relax should not be added when
code model is large.)

Because of the new mask target-flag, get "direct" flags is necessary
when using their target-flags. In addition, code sequence after being
optimized by `MergeBaseOffset` pass may not relaxable any more, so the
relax "bitmask" flag should be removed.
2025-01-20 10:00:05 +08:00
Patryk Wychowaniec
814b34f31e
[AVR] Force relocations for non-encodable jumps (#121498)
This commit changes the branch emission logic so that instead of
throwing the "branch target out of range" error, we emit a relocation
instead.
2025-01-20 09:23:57 +08:00
David Green
f7ebb138c2 [AArch64] Add more funnel shift test coverage. NFC 2025-01-19 18:27:41 +00:00
Simon Pilgrim
6adeda8f55
[X86] combinePTESTCC - fold PTESTC(PCMPEQ(X,0),-1) == PTESTZ(X,X) (#123466)
Simplifies the hidden "all_of(X == 0)" pattern

Fixes #123456
2025-01-19 13:09:17 +00:00
Carl Ritson
f811482a74
[AMDGPU] SIWholeQuadMode: Ensure earliest WQM entry point for PS (#123266)
Ensure shaders running WQM (PS) enter at the earliest point irrespective
of WQM marking.
2025-01-19 15:50:33 +09:00
ssijaric-nv
6789442eb2
[AArch64] Fix a corner case with large stack allocation (#122038)
In the unlikely case where the stack size is greater than 4GB, we may run into
the situation where the local stack size and the callee saved registers stack
size get combined incorrectly when restoring the callee saved registers. This
happens because the stack size in shouldCombineCSRLocalStackBumpInEpilogue
is represented as an 'unsigned', but is passed in as an 'int64_t'. We end up with
something like

$fp, $lr = frame-destroy LDPXi $sp, 536870912

This change just makes 'shouldCombineCSRLocalStackBumpInEpilogue' match
'shouldCombineCSRLocalStackBump' where 'StackBumpBytes' is an 'uint64_t'
2025-01-18 22:09:25 -08:00
Craig Topper
9f7c85f46a
[LegalizeIntegerTypes] Use forceExpandWideMUL in ExpandIntRes_XMULO. (#123432)
This generates basically the same code with the operands commuted, but
gets there with less legalization steps.
2025-01-18 08:37:03 -08:00
Simon Pilgrim
fcedf98d7c [X86] Add test coverage for #123456 2025-01-18 16:01:37 +00:00
David Green
d666616804
[AArch64] Fold swapped sub/SUBS conditions (#121412)
This fold already exists in a couple places (DAG and CGP), where an
icmps operands are swapped to allow CSE with a sub. They do not handle
constants though. This patch adds an AArch64 version that can be more
precise.
2025-01-18 12:12:51 +00:00
Simon Pilgrim
26c9be2b8d
[X86] Only call combineBitcastToBoolVector after legalization (#123386)
Prevents infinite loop between combineBitcastToBoolVector and hoistLogicOpWithSameOpcodeHands, which only performs the "logicop(bitcast(A),bitcast(B)) -> bitcast(logicop(A,B))" upto type legalization.

combineBitcastToBoolVector doesn't care much as its mainly for AVX512 cleanup that X86DomainReassignment can't handle for us.

Fixes #123333
2025-01-18 11:44:46 +00:00
Simon Pilgrim
67c3f2b430
[X86] mayFoldIntoStore - peek through oneuse bitcase users to find a store node (#123366)
mayFoldIntoStore currently just checks the direct (oneuse) user of a
SDValue to check its stored, which prevents cases where we bitcast the
value prior to storing (usually the bitcast will be removed later).

This patch peeks up through oneuse BITCAST nodes chain to see if its
eventually stored.

The main use of mayFoldIntoStore is v8i16 EXTRACT_VECTOR_ELT lowering
which will only use PEXTRW/PEXTRB for index0 extractions (vs the faster
MOVD) if the extracted value will be folded into a store on SSE41+
targets.

Fixes #107086
2025-01-18 14:08:24 +05:30
Philip Reames
143c33c6df
[RISCV] Consider only legally typed splats to be legal shuffles (#123415)
Given the comment, I'd expected test coverage. There was none so let's
do the simple thing which benefits the one thing we have tests for.
2025-01-17 19:13:04 -08:00
Craig Topper
0c6e03eea0
[RISCV] Fold vp.store(vp.reverse(VAL), ADDR, MASK) -> vp.strided.store(VAL, NEW_ADDR, -1, MASK) (#123123)
Co-authored-by: Brandon Wu <brandon.wu@sifive.com>
2025-01-17 14:22:25 -08:00
Philip Reames
078dfd8253 [RISCV] Fix variable naming in recently pre-committed test
I'd swapped the %add/%sub names, and then copied that repeatedly.
Oops.  While updating, remove the nsw as those should be irrelevant
and is another copy-paste mistake on my part.
2025-01-17 13:02:35 -08:00
Philip Reames
ce6e66ddec [RISCV] Add coverage for an upcoming select lowering change
A select between an add and a sub can be either a vrsub followed by
add (reducing register pressure), or a vmacc.  The former will be
implemented in an upcoming review.
2025-01-17 12:16:16 -08:00
Farzon Lotfi
eddeb36cf1
[SPIRV] add pre legalization instruction combine (#122839)
- Add the boilerplate to support instcombine in SPIRV
- instcombine length(X-Y) to distance(X,Y)
- switch HLSL's distance intrinsic to not special case for SPIRV.
- fixes #122766
- This RFC we were requested to add in the infra for pattern matching:
https://discourse.llvm.org/t/rfc-add-targetbuiltins-for-spirv-to-support-hlsl/83329/13
2025-01-17 14:46:14 -05:00
Stanislav Mekhanoshin
fbea21aa52
[AMDGPU] Add test for VALU hoisiting from WWM region. NFC. (#123234)
The test demonstraits a suboptimal VALU hoisting from a WWM
region. As a result we have 2 WWM regions instead of one.
2025-01-17 10:06:44 -08:00
Shubham Sandeep Rastogi
ee1c852252
[DebugInfo][InstrRef] Treat ORRWrr as a copy instr (#123102)
The insturction selector uses the `MachineFunction::copySalvageSSA`
function to insert `DBG_PHIs` or identify a defining instruction for a
copy-like instruction when finalizing Instruction References.

AArch64 has the ORR instruction which is a logical OR with the variants
ORRWrr which refers to a register to register variant, and ORRWrs which
is a register to a shifted register variant.

An ORRWrs where the shift amount is 0, and the zero register ($wzr) is
used is considered a copy, for example:

`$w0 = ORRWrs $wzr, killed $w3, 0`

However an ORRWrr with a zero register is not considered a copy

`$w0 = ORRWrr $wzr, killed $w3`

This causes an issue in the livedebugvalues pass because in aarch64-isel
the instruction is the ORRWrr variant, but is then changed to the ORRWrs
variant before the livedebugvalues pass.

This causes a mismatch between the two passes which leads to a crash in
the livedebugvalues pass.

This patch fixes the issue.
2025-01-17 09:27:36 -08:00
Steven Perron
4b692a95d1
[SPIRV] Expand RWBuffer load and store from HLSL (#122355)
The code pattern that clang will generate for HLSL has changed from the
original plan. This allows the SPIR-V backend to generate code for the
current code generation.

It looks for patterns of the form:

```
%1 = @llvm.spv.resource.handlefrombinding
%2 = @llvm.spv.resource.getpointer(%1, index)
load/store %2
```

These three llvm-ir instruction are treated as a single unit that will

1. Generate or find the global variable identified by the call to
   `resource.handlefrombinding`.
2. Generate an OpLoad of the variable to get the handle to the image.
3. Generate an OpImageRead or OpImageWrite using that handle with the
   given index.

This will generate the OpLoad in the same BB as the read/write.

Note: Now that `resource.handlefrombinding` is not processed on its own,
many existing tests had to be removed. We do not have intrinsics that
are able to use handles to sampled images, input attachments, etc., so
we cannot generate the load of the handle. These tests are removed for
now, and will be added when those resource types are fully implemented.
2025-01-17 12:22:28 -05:00
Cullen Rhodes
f719771f25
Revert "[AArch64] Combine and and lsl into ubfiz" (#123356)
Reverts llvm/llvm-project#118974
2025-01-17 16:53:33 +00:00
Simon Pilgrim
8abbd76cfb [X86] Regenerate VFPCLASS assembly comments. NFC. 2025-01-17 15:10:52 +00:00
Simon Pilgrim
123b24ff97 [X86] avx512fp16-arith.ll - regenerate VPTERNLOG comments 2025-01-17 15:10:52 +00:00
Simon Pilgrim
2f853d851b [X86] Regenerate VMOVSH assembly comments. NFC. 2025-01-17 15:10:52 +00:00
Simon Pilgrim
76569025dd
[X86] Fold (v4i32 (scalar_to_vector (i32 (anyext (bitcast (f16)))))) -> (v4i32 bitcast (v8f16 scalar_to_vector)) (#123338)
This pattern tends to appear during f16 -> f32 promotion

Partially addresses the unnecessary XMM->GPR->XMM moves when working with f16 types (#107086)
2025-01-17 14:46:22 +00:00
Brox Chen
703e9e97d9
[AMDGPU][True16][CodeGen] true16 codegen for bswap (#122849)
true16 codegen pattern for bswap
2025-01-17 09:36:55 -05:00
Phoebe Wang
48803bc8c7
[X86][AMX-AVX512][NFC] Remove P from intrinsic and instruction name (#123270)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965
2025-01-17 22:21:19 +08:00
David Green
eff6b64258 [AArch64][GlobalISel] Update and regenerate some vecreduce and other tests. NFC 2025-01-17 13:19:11 +00:00
Wesley Wiser
41f430a48d
[X86] Don't fold very large offsets into addr displacements during ISel (#121678)
Doing so can cause the resulting displacement after frame layout to
become inexpressible (or cause over/underflow currently during frame
layout).

Fixes the error reported in
https://github.com/llvm/llvm-project/pull/101840#issuecomment-2306975944.
2025-01-17 20:09:00 +07:00
Stanislav Mekhanoshin
21704a685d
[AMDGPU] Fix printing hasInitWholeWave in mir (#123232) 2025-01-17 03:00:02 -08:00
Phoebe Wang
fbb9d49506
[X86][APX] Support APX + AMX-MOVRS/AMX-TRANSPOSE (#123267)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/784266
2025-01-17 17:51:42 +08:00