6470 Commits

Author SHA1 Message Date
Florian Hahn
1797ab36ef
Revert "[LSR] Consider post-inc form when creating extends/truncates."
This reverts commit abfeda5af329b5889db709ff74506e20e0b569e9.
and fe19036e1266d2a90b44725c82b898134906e4c3.

The added assertion triggers during clang bootstrap builds. Revert while
I investigate.
2023-06-17 17:58:41 +01:00
Florian Hahn
fe19036e12
[AMDGPU] Update test after abfeda5af329b58. 2023-06-17 10:15:15 +01:00
Jay Foad
01b512882d [AMDGPU] Generate checks for load-constant tests
Differential Revision: https://reviews.llvm.org/D153139
2023-06-17 06:47:15 +01:00
Matt Arsenault
d9333e360a Revert "AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexp"
This reverts commit 1159c670d40e3ef302264c681fe7e0268a550874.

Accidentally pushed wrong patch
2023-06-16 18:13:07 -04:00
Matt Arsenault
1159c670d4 AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexp 2023-06-16 18:06:27 -04:00
Matt Arsenault
b9c6d9e6c3 AMDGPU: Propagate amdgpu-waves-per-eu with attributor
This will do a value range merging down the callgraph, unlike the
current pass which can only propagate values to undecorated functions
from a kernel.

This one is a bit weird due to the interaction with the implied range
from amdgpu-flat-workgroup-size. At the default group range of 1,1024,
the minimum implied bounds is 4 so this ends up introducing the
attribute on undecorated functions. We could probably simplify this by
ignoring it and propagating the raw values. The subtarget interaction
and the interaction with amdgpu-flat-workgroup-size only really clamp
invalid values (plus the lower bound doesn't seem to do anything as
far as I can tell anyway).
2023-06-16 15:04:08 -04:00
Jay Foad
2124759528 [AMDGPU] Regenerate llvm.amdgcn.s.buffer.load checks 2023-06-16 15:21:17 +01:00
Jay Foad
d065adcb48 [AMDGPU] Regenerate a few checks 2023-06-16 11:39:03 +01:00
Ivan Kosarev
41717fdee1 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 15.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152908
2023-06-16 10:31:35 +01:00
Ivan Kosarev
7a12fbc05f [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 11.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152904
2023-06-16 10:08:32 +01:00
Stanislav Mekhanoshin
4b111dd798 [AMDGPU] Fix VOPD dependency checks during combine
Check superreg/subreg defs of an instruction when checking for
dependencies. This may cause some regressions, but better be
safe than sorry. Changed tests are affected because of the
implicit-defs of the superregs.

Differential Revision: https://reviews.llvm.org/D152943
2023-06-15 11:16:33 -07:00
Matt Arsenault
3928e2d43f AMDGPU: Add baseline test for propagating amdgpu-waves-per-eu 2023-06-15 13:16:25 -04:00
Matt Arsenault
e3547bc21b AMDGPU: Assume llvm.amdgcn.exp2 and log are canonicalizing
This was partially handled for log in SelectionDAG and both were
missed for GlobalISel.
2023-06-15 09:55:15 -04:00
Matt Arsenault
f8cc1b6400 AMDGPU: Delete some stray / dead check prefixes 2023-06-15 09:35:12 -04:00
Matt Arsenault
28f3edd2be AMDGPU: Add llvm.amdgcn.exp2 intrinsic
Provide direct access to v_exp_f32 and v_exp_f16, so we can start
correctly lowering the generic exp intrinsics.

Unfortunately have to break from the usual naming convention of
matching the instruction name and stripping the v_ prefix. exp is
already taken by the export intrinsic. On the clang builtin side, we
have a choice of maintaining the convention to the instruction name,
or following the intrinsic name.
2023-06-15 07:00:07 -04:00
Ivan Kosarev
9aa026e9ff [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 9.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152902
2023-06-15 11:02:08 +01:00
Ivan Kosarev
9792c804f6 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 8.
Reviewed By: Joe_Nash

Differential Revision: https://reviews.llvm.org/D152809
2023-06-15 10:47:04 +01:00
Ivan Kosarev
7680951ac8 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 7.
Reviewed By: Joe_Nash

Differential Revision: https://reviews.llvm.org/D152808
2023-06-15 10:40:58 +01:00
Ivan Kosarev
c2887096f3 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 6.
Reviewed By: Joe_Nash

Differential Revision: https://reviews.llvm.org/D152807
2023-06-15 10:39:31 +01:00
Ivan Kosarev
79c8301478 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 5.
Reviewed By: Joe_Nash

Differential Revision: https://reviews.llvm.org/D152805
2023-06-15 10:28:16 +01:00
Ivan Kosarev
980d2b337e [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 4.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152717
2023-06-15 10:26:41 +01:00
Ivan Kosarev
e9d77cd9b2 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 3.
Reviewed By: Joe_Nash

Differential Revision: https://reviews.llvm.org/D152716
2023-06-15 09:55:25 +01:00
Pravin Jagtap
03d92501f3 [AMDGPU] Enable Atomic Optimizer and Default to Iterative Scan Strategy.
The D147408 implemented new Iterative approach for scan computations
and  added new flag `amdgpu-atomic-optimizer-strategy` which is
defaulted to DPP.

The changeset https://github.com/GPUOpen-Drivers/llpc/pull/2506
adapts to the new changes in LLPC.

This patch enables atomic optimizer pass and selects Iterative
approach for scan computations by default for compute pipeline.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D152649
2023-06-15 01:18:38 -04:00
Carl Ritson
0fd31b2880 [AMDGPU] Place returns on stack if they would violate VGPR limit
Check no VGPRs above configured maximum would be used by a return
when deciding if it can be lowered.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D152912
2023-06-15 14:05:32 +09:00
Carl Ritson
d0c0838705 [AMDGPU] Remove return VGPRs from callee save list
There is no need to generate spill/restore for registers used in
return value.  This matters for amdgpu_gfx calling convention
where CSR and Ret definitions overlap.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D152892
2023-06-15 14:05:32 +09:00
Matt Arsenault
0696240384 LowerMemIntrinsics: Check address space aliasing for memmove expansion
For cases where we cannot insert an addrspacecast, we can still expand
like a memcpy if we know the address spaces cannot alias. Normally
non-aliasing memmoves are optimized to memcpy, but we cannot rely on
that for lowering. If a target has aliasing address spaces that cannot
be casted between, we still have to give up lowering this.
2023-06-14 07:56:58 -04:00
Jay Foad
6c03f402f7 [AMDGPU] Use a common check prefix in regbankselect-amdgcn.s.buffer.load.ll 2023-06-14 12:06:11 +01:00
Ivan Kosarev
150c73a072 [AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 2.
Reviewed By: Joe_Nash

Differential Revision: https://reviews.llvm.org/D152715
2023-06-14 11:49:12 +01:00
Carl Ritson
936c16a3a9 [AMDGPU] Pre-commit test for D152892 (NFC) 2023-06-14 17:14:05 +09:00
Amaury Séchet
a70d5e25f3 [DAGCombine] Make sure combined nodes are added back to the worklist in topological order.
Currently, a node and its users are added back to the worklist in reverse topological order after it is combined. This diff changes that order to be topological. This is part of a larger migration to get the DAGCombiner to process nodes in topological order.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D127115
2023-06-13 09:14:37 +00:00
Matt Arsenault
d0923a7739 AMDGPU: Correct constants used in fast math log expansion
The division between float constants was done with less
precision. Performing the divide in double and truncating to float
provides the same value as used in the library fast math expansion.
2023-06-12 21:11:41 -04:00
Matt Arsenault
1f615b502c AMDGPU: Modernize log codegen tests 2023-06-12 21:11:36 -04:00
Matt Arsenault
eccc89b26c AMDGPU: Add llvm.amdgcn.log intrinsic
This will map directly to the hardware instruction which does not
handle denormals for f32. This will allow moving the generic intrinsic
to be lowered correctly. Also handles selecting the f16 version, but
there's no reason to use it over the generic intrinsic.
2023-06-12 21:10:30 -04:00
Matt Arsenault
ee19fabc98 LowerMemIntrinsics: Handle inserting addrspacecast for memmove lowering
We're missing a trivial non-AA way to check for non-aliasing address
spaces.
2023-06-12 21:10:30 -04:00
Kazu Hirata
9eea63bc9c [AMDGPU] Fix resource-usage-pal.ll 2023-06-12 08:06:46 -07:00
Baptiste
3604fdf18d [AMDGPU] Do not assume stack size for PAL code object indirect calls
There is no need to set a big default stack size for PAL code object indirect
calls. The driver knows the max recursion depth, so it can compute a more
accurate value from the minimum scratch size.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D150609
2023-06-12 10:14:17 -04:00
Ivan Kosarev
d09fa8ff2c [AMDGPU][GFX11] Add test coverage for cases involving conversions from and to fp16 values.
Other such tests, of which there are many, are to be updated with
separate patches.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152557
2023-06-12 13:04:40 +01:00
Matt Arsenault
6d2e5c3445 LowerMemIntrinsics: Skip memmove with different address spaces
This is a quick fix for an assert when the source and dest have
different address spaces. The pointer compare needs to have matching
types, but we can't generically introduce addrspacecast and we don't
know if the address spaces alias.
2023-06-10 12:28:05 -04:00
Matt Arsenault
abff7668ab AMDGPU: Implement known bits functions for min3/max3/med3 2023-06-10 10:58:44 -04:00
Matt Arsenault
f24de950e5 AMDGPU: Add baseline tests for known bits handling of med3 2023-06-10 10:58:39 -04:00
Matt Arsenault
5b657f50b8 AMDGPU: Move LICM after AMDGPUCodeGenPrepare
The commit that added the run says it's to hoist uniform parts of
integer division expansion. That expansion is performed later, so this
didn't do anything in that case. Move this later so the original test
shows the improvement.

This also saves a run of "Canonicalize natural loops". Not sure why
this appears to be still getting a separate loop PM run. Also feels a
bit heavy to run this just for divide. Is there a way to specifically
hoist the divide sequence when it expands?
2023-06-10 07:37:32 -04:00
Matt Arsenault
4c0fc4841b AMDGPU: Mark scalar loads as rematerializable
This should be true, but this is useless as is. The rematerialization
logic only permits rematerialize with constant physical register uses,
so non-constant physregs or virtual register uses (the case that
really matters) are not rematerialized. Add the tests which shows
nothing happens, but should in the future.

Also, all loads should really be rematerializable so in the future
this should apply to all the other kinds.
2023-06-09 21:20:21 -04:00
Matt Arsenault
4e4c351ae5 AMDGPU: Avoid endpgm in middle of block for fallback trap lowering.
This was inserting an s_endpgm in the middle of the block when it has
to be a terminator. Split the block and insert a branch to a new block
with the trap if it's not in a terminator position.

Fixes verifier error on LDS in function with no trap support (and
other trap sources).
2023-06-09 21:04:38 -04:00
Matt Arsenault
3c848194f2 CodeGen: Expand memory intrinsics in PreISelIntrinsicLowering
Expand large or unknown size memory intrinsics into loops in the
default lowering pipeline if the target doesn't have the corresponding
libfunc. Previously AMDGPU had a custom pass which existed to call the
expansion utilities.

With a default no-libcall option, we can remove the libfunc checks in
LoopIdiomRecognize for these, which never made any sense. This also
provides a path to lifting the immarg restriction on
llvm.memcpy.inline.

There seems to be a bug where TLI reports functions as available if
you use -march and not -mtriple.
2023-06-09 21:04:37 -04:00
Matt Arsenault
4469aff148 AMDGPU: Add baseline tests for integer mad matching
Test some clpeak-like patterns with multiple use muls.
2023-06-09 19:17:56 -04:00
David Stuttard
90431ca2e0 Reland [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-09 12:34:00 +01:00
pvanhout
ecbd37d5a3 [AMDGPU] Port no-hsa-graphic-shaders.ll to code object V4
Split from D146023

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D152432
2023-06-09 09:07:53 +02:00
Pravin Jagtap
f6c8a8e9cb [AMDGPU] Iterative scan implementation for atomic optimizer.
This patch provides an alternative implementation to DPP for Scan Computations.

An alternative implementation iterates over all active lanes of Wavefront
using llvm.cttz and performs the following steps:
    1.  Read the value that needs to be atomically incremented using
        llvm.amdgcn.readlane intrinsic
    2.  Accumulate the result.
    3.  Update the scan result using llvm.amdgcn.writelane intrinsic
        if intermediate scan results are needed later in the kernel.

Reviewed By: arsenm, cdevadas

Differential Revision: https://reviews.llvm.org/D147408
2023-06-09 01:08:44 -04:00
Amara Emerson
086601eac2 [GlobalISel] Implement some binary reassociations, G_ADD for now
- (op (op X, C1), C2) -> (op X, (op C1, C2))
- (op (op X, C1), Y) -> (op (op X, Y), C1)

Some code duplication with the G_PTR_ADD reassociations unfortunately but no
easy way to avoid it that I can see.

Differential Revision: https://reviews.llvm.org/D150230
2023-06-08 21:14:58 -07:00
Matt Arsenault
c01f284fbb AMDGPU: Fix regressions in integer mad matching
Undo the canonicalize done in
0cfc6510323fbb5a56a5de23cbc65f7cc30fd34c. Restores some regressed
matching of integer mad. The selection patterns fo the actual mads
don't seem to be properly commuting, so some of the commuted cases are
still missed.

Fixes: SWDEV-363009
2023-06-08 16:48:47 -04:00