7894 Commits

Author SHA1 Message Date
Jeffrey Byrnes
f903e3ec77 [AMDGPU] Reset kill flags for multiple uses of SDWAInst Ops
Change-Id: I8b56d86a55c397623567945a87ad2f55749680bc
2024-07-01 09:14:02 -07:00
Matt Arsenault
0d88f662ff GlobalISel: ComputeNumSignBits from load range metadata
We're missing SimplifyDemandedBits styles of optimizations,
so one case differs from the DAG from not trimming the constant.
The other case is an optimization we get that the DAG doesn't do to
split the 64-bit shift.

https://reviews.llvm.org/D138082
2024-07-01 15:26:50 +02:00
Matt Arsenault
7032076242
GlobalISel: Drop vector range metadata on bitcast lowering (#97279)
If we are reinterpreting the type, the range metadata also needs to be
converted. I believe the DAG has the same bug.
2024-07-01 15:26:09 +02:00
Matt Arsenault
8eee6d33f7
DAG: Call SimplifyDemandedBits on copysign value operand (#97180)
So far the only cases that seem to benefit are the weird
copysign with different typed inputs.
2024-07-01 12:29:11 +02:00
Matt Arsenault
db9252b115
DAG: Call SimplifyDemandedBits on fcopysign sign value (#97151)
Math library code has quite a few places with complex bit
logic that are ultimately fed into a copysign. This helps
avoid some regressions in a future patch.

This assumes the position in the float type, which should
at least be valid for IEEE types. Not sure if we need to guard
against ppc_fp128 or anything else weird.

There appears to be some value in simplifying the value operand
as well, but I'll address that separately.
2024-07-01 12:19:17 +02:00
Matt Arsenault
c769dc457c
AMDGPU: Add baseline test for copysign combine (#97150)
Pre-commit tests showing we try to SimplifyDemandedBits on the
sign operand.
2024-07-01 12:14:57 +02:00
Matt Arsenault
3562001007 AMDGPU: Regenerate test checks to avoid spurious diff 2024-07-01 11:10:17 +02:00
Nuno Lopes
0e6257fbc2 SSAUpdater: use poison instead of undef in phi entries for unreachable predecessors 2024-06-30 11:51:30 +01:00
Matt Arsenault
76bc071418
DAG: Fix assert when legalizing v3f16 ldexp (#97098)
For the v3f16.v3i32 case, the v3f16 would request widening
to v4f16, but the v3i32 does not require widening to be a legal
type, so GetWidenedVector would fail. We need to widen the exponent
vector to the same element count as the result.

 Fixes: SWDEV-470951
2024-06-30 08:29:20 +02:00
Vitaly Buka
3e53c97d33
Revert "[AMDGPU] Add IR LiveReg type-based optimization" (#97138)
Part of #66838.

https://lab.llvm.org/buildbot/#/builders/52/builds/404
https://lab.llvm.org/buildbot/#/builders/55/builds/358
https://lab.llvm.org/buildbot/#/builders/164/builds/518

This reverts commit ded956440739ae326a99cbaef18ce4362e972679.
2024-06-28 23:18:26 -07:00
Vigneshwar Jayakumar
d2c817df84
[AMDGPU] Fix DynLDS causing crash when LowerLDS is run at fullLTO pipeline (#96038)
Direct mapped dynamic LDS is not lowered in the LowerLDSModule pass.
Hence it is not marked with an absolute symbol. When the LowerLDS pass is
rerun in LTO, compilation fails with an assert "cannot mix abs and non-abs LDVs".
This patch adds an additional check for direct mapped dynLDS to skip the assert.

Fixes SWDEV-454281
2024-06-28 21:05:48 -05:00
Jeffrey Byrnes
ded9564407 [AMDGPU] Add IR LiveReg type-based optimization
Change-Id: Ia0d11b79b8302e79247fe193ccabc0dad2d359a0
2024-06-28 15:01:39 -07:00
Matt Arsenault
2df2373eb8
DAG/GlobalISel: Set disjoint for or in copysign lowering (#97057)
We masked out the sign bit from one value, and the non-sign bits
from the other so there should be no common bits set.

No idea how to test this on the DAG path, other than scraping
the debug logs. A few targets hit this path with f16 values, but
the resulting i16 ors get anyext promoted and lose the disjoint
flag. In the fp128 case, PPC gets further and the or loses the flag
somewhere else later. Adding a haveNoCommonBits assert shows this
works though.
2024-06-28 23:03:39 +02:00
Matt Arsenault
28d142a485 AMDGPU/GlobalISel: Make pk f16 atomicrmw fadd legal for gfx908
The subtarget features for these are a bit of a mess; the no return
version should probably be implied by the with-return feature.
2024-06-28 11:33:42 +02:00
isuckatcs
937d79bc9d
[GlobalISel][AArch64][AMDGPU] Expand FPOWI into series of multiplication (#95217)
SelectionDAG already converts FPOWI into a series of optimized multiplications, 
this patch introduces the same optimization into GlobalISel.
2024-06-28 09:57:50 +02:00
Matt Arsenault
a2a73d892a
AMDGPU: Fix no return atomicrmw fadd v2f16 selection for gfx908 (#96948)
We previously would always expand this with a cmpxchg loop, while
it should be the same conditions as the f32 case (except for the
denormal concern).
2024-06-27 21:17:16 +02:00
Jay Foad
4e70720139 [AMDGPU] Add some gfx1200 test coverage 2024-06-27 14:53:59 +01:00
Matt Arsenault
4477ff6836
AMDGPU: Remove ds_fmin/ds_fmax intrinsics (#96739)
These have been replaced with atomicrmw.
2024-06-27 15:35:24 +02:00
Jay Foad
bf536cc7db
[AMDGPU] Fix unwanted LICM/CSE of llvm.amdgcn.pops.exiting.wave.id (#96190)
Mark both the intrinsic and the selected MachineInstr as having side
effects to prevent MachineLICM and MachineCSE from moving/removing them.
2024-06-27 09:27:52 +01:00
Janek van Oirschot
17eaa23f7e
[AMDGPU] MCExpr-ify AMDGPU HSAMetadata (#94788)
Enables MCExpr for HSAMetadata, particularly, HSAMetadata's msgpack format.
2024-06-26 16:39:08 +01:00
Vikram Hegde
35f7b60aa6
[AMDGPU] Extend permlane16, permlanex16 and permlane64 intrinsic lowering for generic types (#92725)
These are incremental changes over #89217 , with core logic being the
same. This patch along with #89217 and #91190 should get us ready to enable 64
bit optimizations in atomic optimizer.
2024-06-26 09:24:09 +05:30
Matt Arsenault
4f80f362a5 AMDGPU: Add new metadata and expand atomicrmw fadd expansion tests 2024-06-25 23:42:48 +02:00
Matt Arsenault
8bba070ef8 AMDGPU: Expand testing of atomicrmw fmin/fmax lowering
Cover amdgpu.no.fine.grained.memory vs. amdgpu.no.remote.memory.
2024-06-25 23:42:48 +02:00
Jay Foad
aaf50bf34f
[AMDGPU] Disallow negative s_load offsets in isLegalAddressingMode (#91327) 2024-06-25 17:43:00 +01:00
Matt Arsenault
889f3c5741
AMDGPU: Handle legal v2bf16 atomicrmw fadd for gfx12 (#95930)
Annoyingly gfx90a/940 support this for global/flat but not buffer.
2024-06-25 17:45:34 +02:00
Vikram Hegde
5feb32ba92
[AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (#89217)
This patch is intended to be the first of a series with end goal to
adapt atomic optimizer pass to support i64 and f64 operations (along
with removing all unnecessary bitcasts). This legalizes 64 bit readlane,
writelane and readfirstlane ops pre-ISel

---------

Co-authored-by: vikramRH <vikhegde@amd.com>
2024-06-25 14:35:19 +05:30
vangthao95
3aef525aa4
[AMDGPU] Fix negative immediate offset for unbuffered smem loads (#89165)
For unbuffered smem loads, it is illegal for the immediate offset to be
negative if the resulting IOFFSET + (SGPR[Offset] or M0 or zero) is
negative.

New PR of https://github.com/llvm/llvm-project/pull/79553.
2024-06-24 14:18:23 -07:00
Mariusz Sikora
689c5c4829
[AMDGPU] Set total VGPRs to 1536 for gfx12 (#96272)
- Use Feature1_5xVGPRs
2024-06-24 13:26:03 +02:00
vg0204
c2fc7f75f6 Revert "[AMDGPU]Optimize SGPR spills (#93668)"
This reverts commit 4b9112e88a998ce620e4683548f2afd17cc5fe95. A separate
issue(#96353) describing it has been opened to further keep its track.
2024-06-24 12:36:36 +05:30
Matt Arsenault
70c8b9c24a
AMDGPU: Remove ds atomic fadd intrinsics (#95396)
These have been replaced with atomicrmw fadd
2024-06-23 10:30:20 +02:00
Matt Arsenault
414c74149c
AMDGPU: Start selecting buffer fat pointer atomicrmw fmin/fmax (#95593) 2024-06-23 10:13:42 +02:00
Matt Arsenault
a440a96ec2
AMDGPU: Start selecting flat/global atomicrmw fmin/fmax. (#95592)
Define subtarget features for atomic fmin/fmax support.

The flat/global support is a real messe. We had float/double support at
the beginning in gfx6 and gfx7. gfx8 removed these. gfx10 reintroduced them.
gfx11 removed the f64 versions again.

gfx9 partially reintroduced them, in gfx90a and gfx940 but only for f64.
2024-06-23 10:10:41 +02:00
Matt Arsenault
73a2232720
AMDGPU: Materialize bitwise not of inline immediates (#95960)
If we have a bitwise negated inline immediate, we can materialize
it with s_not_b32/v_not_b32. This mirrors the current bitreverse
handling.
    
As a side effect, we also now handle the bitreversed FP immediate
case.
    
One test shows some VOPD regressions on gfx11 which should
probably be fixed. Previously the 2 v_mov_b32 could be packed,
but now the mismatched opcode + mov can't. This problem already
already existed for the bfrev case, it just happens more often now.
2024-06-22 00:40:59 +02:00
Matt Arsenault
c026024ff9
AMDGPU: Legalize v2f16 atomicrmw fadd for buffer fat pointers (#95929)
Unfortunately the v2bf16 case is complicated because gfx90a
doesn't support it, while it does for global/flat.
2024-06-21 13:55:06 +02:00
Michael Bedy
edf2d0a95e
[AMDGPU] Introduce a pseudo mnemonic for S_DELAY_ALU in MIR. (#96004) 2024-06-20 15:59:08 -04:00
Jay Foad
33c9331a92 [AMDGPU] Precommit a test for llvm.amdgcn.pops.exiting.wave.id 2024-06-20 14:27:35 +01:00
Jay Foad
90779fdc19
[AMDGPU] Preserve chain when selecting llvm.amdgcn.pops.exiting.wave.id (#96167)
Without this SelectionDAG could fail assertions when using the intrinsic
in a non-entry BB.
2024-06-20 12:30:34 +01:00
Pierre van Houtryve
f0897ea4bb
[MachineLICM] Work-around Incomplete RegUnits (#95926)
Reverts the behavior introduced by 770393b while keeping the refactored
code.

Fixes a miscompile on AArch64, at the cost of a small regression on
AMDGPU.
#96146 opened to investigate the issue
2024-06-20 10:59:00 +02:00
Nikita Popov
6c01011db0
[IR] Mark shl constant expression as undesirable (#95940)
Mark shl constant expressions undesirable, so that they are no longer
automatically created by IRBuilder, constant folding, etc.

This is in preparation for removing them entirely.
2024-06-19 09:10:28 +02:00
Matt Arsenault
d8b63b680d
AMDGPU: Don't fold clamp/omod modifiers without nofpexcept (#95950) 2024-06-18 23:55:49 +02:00
Matt Arsenault
89fd195092
AMDGPU: Fix buffer load/store of pointers (#95379)
Make sure we test all the address spaces since this support isn't
free in gisel.
2024-06-18 20:52:06 +02:00
Matt Arsenault
b932da16b7
AMDGPU: Fix vector handling in pown libcall simplification (#95832)
The isIntegerTy check would not work as you would hope in
the vector case.
2024-06-18 19:17:42 +02:00
Matt Arsenault
62b5196be0
DAG: Fix asserting on invalid inline asm constraints (#95935) 2024-06-18 18:51:29 +02:00
Matt Arsenault
8520061281
AMDGPU: Support local atomicrmw fmin/fmax for float/double (#95590)
This has always been supported. Somehow, we ended up with 2
copies of clang builtins for this case, and the newer one
erroneously requires gfx8-insts.
2024-06-18 18:34:34 +02:00
Vikash Gupta
4b9112e88a
[AMDGPU]Optimize SGPR spills (#93668)
This PR is dependent on
[#93779](https://github.com/llvm/llvm-project/pull/93779).

As currently, each SGPR Spills are lowered to go into distinct stack
slots in stack frame after SGPR allocation phase. Therefore, this patch
utilizes the capability of StackSlotColoring to ensure the stack slot
sharing if possible for stack frame index, where the SGPR spills are
occuring in the non-interfering region.

StackSlotColoring is introduced immediately after SGPR register
allocation, just to ensure that any further lowering happens on the
optimally allocated stack slots, with certain flags to indicate the
preservation of certain analysis result later to be used by RA of other
register classes.
2024-06-18 20:55:31 +05:30
David Green
1a0a4d0b22
[GlobalISel] Allow more illegal vector types in params/returns. (#95514)
This helps some of the testing of illegal types, allowing us to pass
them into and out of functions.

The AMD tests no longer fail, but I am unsure whether they are correct.
They fail later on in the pipeline for GISel, and during lowering ret
for SDAG.
2024-06-18 13:20:49 +01:00
Matt Arsenault
eda9ff899f
AMDGPU: Flat instructions do not have signed offsets gfx7-gfx11 (#95852)
Fixes some atomicrmw fadd and intrinsic cases
2024-06-18 13:20:34 +02:00
Matt Arsenault
1d97f8f78a AMDGPU: Add some addressing mode tests for flat atomic intrinsics
These are incorrectly matching with signed offsets.
2024-06-18 12:00:42 +02:00
Matt Arsenault
9f8e7c3a01
AMDGPU: Create pseudo to real mapping for flat/buffer atomic fmin/fmax (#95591)
The global/flat/buffer atomic fmin/fmax situation is a mess. These
instructions have been renamed 3 times. We currently have
separate pseudos defined for the same opcodes with the different names
(e.g. GLOBAL_ATOMIC_MIN_F64 from gfx90a and GLOBAL_ATOMIC_FMIN_X2 from gfx10).

Use the _FMIN versions as the canonical name for the f32 versions. Use the
_MIN_F64 style as the canonical name for the f64 case. This is because
gfx90a has the most sensible names, but does not have the f32 versions.t sho

Wire through the pseudo to use for the instruction properties vs. the assembly
name like in other cases. This will simplify handling of direct atomicrmw selection.

This will simplify directly selecting these from atomicrmw.
2024-06-18 10:34:09 +02:00
Matt Arsenault
3b997294d6
AMDGPU: Remove .v2bf16 buffer atomic fadd intrinsics (#95783)
These are redundant with the unsuffixed versions, and have a name
collision with surprising behavior when the base intrinsic is used with
v2bf16.

The global and flat variants should be removed too, but those are complicated
due to using v2i16 in place of the natural v2bf16. Those cases can soon be
completely deleted in favor of atomicrmw.

The GlobalISel codegen change is broken and substitutes handling as bf16
for handling as f16, but it's a bug that this passed the IRTranslator in the first
place.
2024-06-17 21:44:52 +02:00