9209 Commits

Author SHA1 Message Date
Carl Ritson
1f6648ccaa
[AMDGPU] AMDGPUPromoteAlloca: increase default max-regs to 32 (#155076)
Increase promote-alloca-to-vector-max-regs to 32 from 16.
This restores default promotion of 16 x double which was disabled by
#127973.

Fixes SWDEV-525817.
2025-08-26 09:30:16 +09:00
Stanislav Mekhanoshin
94e4ef5f65
[AMDGPU] gfx1250 waitcnt related codegen tests update. NFC (#155317) 2025-08-25 15:23:59 -07:00
Stanislav Mekhanoshin
f3ea46a31b
[AMDGPU] Add few missing gfx1250 codegen tests. NFC (#155314) 2025-08-25 15:22:33 -07:00
Stanislav Mekhanoshin
f13a35c447
[AMDGPU] gfx1250 intrinscs codegen tests update. NFC (#155312) 2025-08-25 15:18:27 -07:00
Stanislav Mekhanoshin
68107bb360
[AMDGPU] gfx1250 run line in the fp atomics test. NFC (#155306) 2025-08-25 15:15:22 -07:00
Stanislav Mekhanoshin
43a9b666b6
[AMDGPU] gfx1250 trans instructions bf16 codegen tests update. NFC (#155310)
Co-authored-by: Shilei Tian <Shilei.Tian@amd.com>
2025-08-25 15:10:12 -07:00
Stanislav Mekhanoshin
efd8143c24
[AMDGPU] gfx1250 codegen load tests update. NFC. (#155305) 2025-08-25 15:09:41 -07:00
Stanislav Mekhanoshin
e903a6c2b5
[AMDGPU] gfx1250 SADDR tests update. NFC (#155307) 2025-08-25 15:07:15 -07:00
Stanislav Mekhanoshin
c6c48b4585
[AMDGPU] gfx1250 s_buffer_load tests. NFC. (#155295) 2025-08-25 14:32:50 -07:00
Stanislav Mekhanoshin
c8b46f3c5d
[AMDGPU] gfx1250 sram-ecc feature codegen tests. NFC. (#155293)
sram-ecc is always on.
2025-08-25 14:32:29 -07:00
Stanislav Mekhanoshin
b412d7d111
[AMDGPU] gfx1250 min/max codegen tests. NFC. (#155292) 2025-08-25 14:32:08 -07:00
Victor Mustya
6a5cb5afdc
[GISel] Fix crash in GlobalISel utils method (#153334)
The `getDefSrcRegIgnoringCopies` method in GlobalISel Utils crashed when
the first operand of the input instruction was not a register, e.g.,
the `INLINEASM` instruction has a non-register first operand.

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-08-25 12:59:01 -07:00
Matt Arsenault
db024764c1
AMDGPU: Fix not diagnosing unaligned VGPRs for vsrc operands (#155104)
This was not checking the alignment requirement for 64-bit
operands which accept inline immediates. Not all custom operand
types were handled in the switch, so round out with explicit
handling of all enum values, and change the default to use
the default checks for unhandled cases.

Fixes #155095
2025-08-25 17:42:58 +09:00
Nicolai Hähnle
46762421c3
AMDGPU/GFX12: Do not wait unnecessarily before barriers (#154970)
The barrier intrinsic itself should not have memory semantics. Frontends
should use appropriate fence instructions for memory effects, and some
frontends want to rely on that for performance (e.g. wait only for LDS
before a barrier).

See the code comment for more detail.
2025-08-23 00:07:59 -07:00
Matt Arsenault
52ed03db59
AMDGPU: Simplify foldImmediate with register class based checks (#154682)
Generalize the code over the properties of the mov instruction,
rather than maintaining parallel logic to figure out the type
of mov to use. I've maintained the behavior with 16-bit physical
SGPRs, though I think the behavior here is broken and corrupting
any value that happens to be live in the high bits. It just happens
there's no way to separately write to those with a real instruction
but I don't think we should be trying to make assumptions around
that property.

This is NFC-ish. It now does a better job with imm pseudos which
practically won't reach here. This also will make it easier
to support more folds in a future patch.

I added a couple of new tests with 16-bit extract of 64-bit sources.
2025-08-23 02:13:50 +00:00
Anshil Gandhi
7dfd5ba811
[AMDGPU] Update codegen tests for PR #154069 (#154862) 2025-08-22 07:58:21 -06:00
Simon Pilgrim
2a79ef66eb
[AMDGPU] canCreateUndefOrPoisonForTargetNode - BFE_I32/U32 can't create poison/undef (#154932)
Add AMDGPUTargetLowering::canCreateUndefOrPoisonForTargetNode handler
and tag BFE_I32/U32 nodes as they can only propagate poison, not create
poison/undef.

Fighting some of the remaining regressions in #152107
2025-08-22 12:14:45 +00:00
Simon Pilgrim
d8769bb5b7 [AMDGPU] bf16-conversions.ll - regenerate checks
Reduce diffs in #152107
2025-08-22 12:20:50 +01:00
Abhinav Garg
bfc16510c7
[AMDGPU] Regenerate test case to cover gfx10 check lines. (#154909)
Check lines for GFX10 is missing in this test case. Regenerate to fix
test case.
2025-08-22 15:00:28 +05:30
Pierre van Houtryve
4ab5efd48d
[AMDGPU][gfx1250] Add memory legalizer tests (NFC) (#154725) 2025-08-22 10:14:09 +02:00
Matt Arsenault
2b46f31ee3
AMDGPU: Sign extend immediates for 32-bit subregister extracts (#154870)
extractSubregFromImm previously would sign extend the 16-bit subregister
extracts, but not the 32-bit. We try to consistently store immediates
as sign extended, since not doing it can result in misreported
isInlineImmediate checks.
2025-08-22 16:50:36 +09:00
Stanislav Mekhanoshin
e0945dfa30
[AMDGPU] Add test to show failure with SRC_*_HI registers. NFC. (#154828)
Since src_{private|shared}_{base|limit} registers are added and
are not artifical compiler happily uses it when it can. In HW
these registers do not exist and the encoding belongs to their
64-bit super-register or 32-bit low register. Same instructions
will produce relocation if run through asm.
2025-08-22 00:50:25 -07:00
paperchalice
945a186089
[DAGCombiner] Remove most UnsafeFPMath references (#146295)
This pull request removes all references to `UnsafeFPMath` in dag
combiner except FP_ROUND.
- Set fast math flags in some tests.
2025-08-22 15:27:25 +08:00
Matt Arsenault
b1b5102624
AMDGPU: Start considering new atomicrmw metadata on integer operations (#122138)
Start considering !amdgpu.no.remote.memory.access and
!amdgpu.no.fine.grained.host.memory metadata when deciding to expand
integer atomic operations. This does not yet attempt to accurately
handle fadd/fmin/fmax, which are trickier and require migrating the
old "amdgpu-unsafe-fp-atomics" attribute.
2025-08-22 05:29:36 +00:00
Matt Arsenault
fc5fcc0c95
AMDGPU: Start using AV_MOV_B64_IMM_PSEUDO (#154500) 2025-08-22 13:59:36 +09:00
Matt Arsenault
01f785cac4
AMDGPU: Expand remaining system atomic operations (#122137)
System scope atomics need to use cmpxchg loops if we know
nothing about the allocation the address is from.
aea5980e26e6a87dab9f8acb10eb3a59dd143cb1 started this, this
expands the set to cover the remaining integer operations.

Don't expand xchg and add, those theoretically should work over PCIe.
This is a pre-commit which will introduce performance regressions.
Subsequent changes will add handling of new atomicrmw metadata, which
will avoid the expansion.

Note this still isn't conservative enough; we do need to expand
some device scope atomics if the memory is in fine-grained remote
memory.
2025-08-22 13:55:04 +09:00
Alex MacLean
4a9d2187ee
[SeparateConstOffsetFromGEP] propagate const offset through GEP chains (#143470)
When separating the constant offset from a GEP, if the pointer operand
is a constant ptradd (likely generated when we performed this transform
on that GEP), we accumulate the offset into the current offset. This
ensures that when there is a chain of GEPs the constant offset reaches
the final memory instruction where it can likely be folded into the
addressing.
2025-08-21 13:37:24 -07:00
Matt Arsenault
b614975e97 AMDGPU: Fix expensive_checks machine verifier errors in new tests 2025-08-21 22:33:26 +09:00
Matt Arsenault
13ae82d6ea
AMDGPU: Fix broken check lines in test (#154690)
SelectionDAG checks were dropped, regenerate the test to
restore them.
2025-08-21 21:00:55 +09:00
Matt Arsenault
e414585545
AMDGPU: Add baseline test for mfma rewrite with phi (#153021) 2025-08-21 10:25:05 +09:00
Matt Arsenault
bcf41e03c7
AMDGPU: Add baseline test for vgpr mfma with copied-from AGPR (#153020) 2025-08-21 10:24:27 +09:00
Matt Arsenault
eefad7438c
AMDGPU: Handle rewriting VGPR MFMA to AGPR with subregister copies (#153019)
This should address the case where the result isn't fully used,
resulting in partial copy bundles from the MFMA result.
2025-08-21 01:17:03 +00:00
Matt Arsenault
744cd8a9c6
AMDGPU: Add some baseline test for mfma rewrite with subregister copies (#153018)
Currently only cases rooted at a full copy of an MFMA result are
handled.
Prepare to relax that by testing more intricate subregister usage.

Currently only full copies are handled, add some tests to help work
towards handling subregisters.
2025-08-21 00:39:39 +00:00
Matt Arsenault
156f3fce54
AMDGPU: Handle rewriting VGPR MFMAs with immediate src2 (#153016) 2025-08-21 09:09:24 +09:00
Matt Arsenault
3a0fa12752
DAG: Handle half spanning extract_subvector in type legalization (#154101)
Previously it would just assert if the extract needed elements from
both halves. Extract the individual elements from both halves and
create a new vector, as the simplest implementation. This could
try to do better and create a partial extract or shuffle (or
maybe that's best left for the combiner to figure out later).

Fixes secondary issue noticed as part of #153808
2025-08-21 00:05:12 +00:00
Matt Arsenault
ff5f396dac
AMDGPU: Handle rewriting non-tied MFMA to AGPR form (#153015)
If src2 and dst aren't the same register, to fold a copy
to AGPR into the instruction we also need to reassign src2
to an available AGPR. All the other uses of src2 also need
to be compatible with the AGPR replacement in order to avoid
inserting other copies somewhere else.

Perform this transform, after verifying all other uses are
compatible with AGPR, and have an available AGPR available at
all points (which effectively means rewriting a full chain of
mfmas and load/store at once).
2025-08-21 08:16:56 +09:00
Gang Chen
575fad2892
[AMDGPU] Upstream the Support for array of named barriers (#154604) 2025-08-20 14:53:03 -07:00
Gang Chen
60dbde69cd
[AMDGPU] report named barrier cnt part2 (#154588) 2025-08-20 12:00:45 -07:00
Mirko Brkušanin
80f3b376b3
[AMDGPU][GlobalISel] Combine for breaking s64 and/or into two s32 insts (#151731)
When either one of the operands is all ones in high or low parts,
splitting these opens up other opportunities for combines. One of two
new instructions will either be removed or become a simple copy.
2025-08-20 17:32:29 +02:00
Janek van Oirschot
40e1510146
[AMDGPU][NFC] Enable gfx942 for more tests (#154363)
Enable gfx942 for tests that are affected by the an AMDGPU bitcast
constant combine (#154115)

Expecting to see more tests affected in aforementioned PR after rebase
on top of this PR
2025-08-20 15:46:26 +01:00
Brox Chen
c50ed05cad
[AMDGPU][True16][CodeGen] use vgpr16 for zext patterns (reopen #153894) (#154211)
recreate this patch from
https://github.com/llvm/llvm-project/pull/153894

It seems ISel sliently ignore the `i64 = zext i16` with a chained
`reg_sequence` pattern and thus this is causing a selection failure in
hip test. Recreate a new patch with an alternative pattern, and added a
ll test global-extload-gfx11plus.ll
2025-08-20 10:26:49 -04:00
Matt Arsenault
694a488708
AMDGPU: Add pseudoinstruction for 64-bit agpr or vgpr constants (#154499)
64-bit version of 7425af4b7aaa31da10bd1bc7996d3bb212c79d88. We
still need to lower to 32-bit v_accagpr_write_b32s, so this has
a unique value restriction that requires both halves of the constant
to be 32-bit inline immediates. This only introduces the new
pseudo definitions, but doesn't try to use them yet.
2025-08-20 22:54:37 +09:00
Harrison Hao
23a5a7bef3
[AMDGPU] Support merging 16-bit and 8-bit TBUFFER load/store instruction (#145078)
SILoadStoreOptimizer can now recognise consecutive 16-bit and 8-bit
`TBUFFER_LOAD`/`TBUFFER_STORE` instructions that each write

* a single component (`X`), or
* two components (`XY`),

and fold them into the wider native variants:

```
X + X          -->  XY
X + X + X + X  -->  XYZW
XY + XY        -->  XYZW
X + X + X      -->  XYZ
XY + X         -->  XYZ
```

The optimisation cuts the number of TBUFFER instructions, shrinking code
size and improving memory throughput.
2025-08-20 21:16:25 +08:00
Matt Arsenault
c876d53378
DAG: Avoid creating illegal extract_subvector in legalizer (#154100)
Fixes #153808
2025-08-20 20:55:05 +09:00
Shilei Tian
7905d5e364
[AMDGPU] Add support for store to constant address space (#153835)
Since we don't stores to the constant address space as IR verifier
errors, we need to support their lowering.

Fixes SWDEV-499366.
2025-08-19 21:04:35 -04:00
Matt Arsenault
1f0af171cd
AMDGPU: Fix using illegal extract_subvector indexes (#154098) 2025-08-20 00:35:09 +00:00
Gang Chen
ef68d1587d
[AMDGPU] upstream barrier count reporting part1 (#154409) 2025-08-19 16:42:31 -07:00
Shilei Tian
b170f17861
[AMDGPU] Add support for safe bfloat16 fdiv on targets with bf16 trans instructions (#154373)
Recent changes introduced custom lowering for bf16 fdiv on targets that
support bf16 trans instructions, but only covered the unsafe version.
This PR extends that support to the safe variant.

For the safe version, the op is lowered by converting to float,
performing the div in float, and converting the result back to bf16.
This matches the behavior on targets that don't support bf16 trans
instructions.

Fixes SWDEV-550381.
2025-08-19 16:03:45 -04:00
Pierre van Houtryve
6f7c77fe90
[AMDGPU] Check noalias.addrspace in mayAccessScratchThroughFlat (#151319)
PR #149247 made the MD accessible by the backend so we can now leverage
it in the memory model. The first use case here is detecting if a flat op
can access scratch memory.
Benefits both the MemoryLegalizer and InsertWaitCnt.
2025-08-19 07:42:59 +02:00
Shilei Tian
1f6e13a161 Revert "[AMDGPU][Attributor] Infer inreg attribute in AMDGPUAttributor (#146720)"
This reverts commit 84ab301554f8b8b16b94263a57b091b07e9204f2 because it breaks
several AMDGPU test bots.
2025-08-18 22:59:52 -04:00