Commit Graph

2783 Commits

Author SHA1 Message Date
Matt Arsenault 53208ba3c0 AMDGPU: Fix i16 arithmetic pattern redundancy
There were 2 problems here. First, these patterns were duplicated to
handle the inverted shift operands instead of using the commuted
PatFrags.

Second, the point of the zext folding patterns don't apply to the
non-0ing high subtargets. They should be skipped instead of inserting
the extension. The zeroing high code would be emitted when necessary
anyway. This was also emitting unnecessary zexts in cases where the
high bits were undefined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374092 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08 17:36:38 +00:00
Tom Stellard 80fd3bf4c9 AMDGPU: Add offsets to MMO when lowering buffer intrinsics
Summary:
Without offsets on the MachineMemOperands (MMOs),
MachineInstr::mayAlias() will return true for all reads and writes to the
same resource descriptor.  This leads to O(N^2) complexity in the MachineScheduler
when analyzing dependencies of buffer loads and stores.  It also limits
the SILoadStoreOptimizer from merging more instructions.

This patch reduces the compile time of one pathological compute shader
from 12 seconds to 1 second.

Reviewers: arsenm, nhaehnle

Reviewed By: arsenm

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, jfb, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374087 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08 17:04:51 +00:00
Amaury Sechet 265327e7cf (Re)generate various tests. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374074 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08 16:16:26 +00:00
Nicolai Haehnle c54901d360 AMDGPU: Propagate undef flag during pre-RA exec mask optimizations
Summary: Issue: https://github.com/GPUOpen-Drivers/llpc/issues/204

Reviewers: arsenm, rampitec

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374041 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08 12:46:32 +00:00
Nicolai Haehnle aef8d68ace MachineSSAUpdater: insert IMPLICIT_DEF at top of basic block
Summary:
When getValueInMiddleOfBlock happens to be called for a basic block
that has no incoming value at all, an IMPLICIT_DEF is inserted in that
block via GetValueAtEndOfBlockInternal. This IMPLICIT_DEF must be at
the top of its basic block or it will likely not reach the use that
the caller intends to insert.

Issue: https://github.com/GPUOpen-Drivers/llpc/issues/204

Reviewers: arsenm, rampitec

Subscribers: jvesely, wdng, hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374040 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08 12:46:20 +00:00
Matt Arsenault e6f17ad250 AMDGPU/GlobalISel: Clamp G_SITOFP/G_UITOFP sources
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373989 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 23:33:08 +00:00
Matt Arsenault ee3a634ba6 AMDGPU/GlobalISel: Handle more G_INSERT cases
Start manually writing a table to get the subreg index. TableGen
should probably generate this, but I'm not sure what it looks like in
the arbitrary case where subregisters are allowed to not fully cover
the super-registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373947 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 19:16:26 +00:00
Matt Arsenault 0401164ba7 GlobalISel: Partially implement lower for G_INSERT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373946 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 19:13:27 +00:00
Matt Arsenault f9eb3dcabc AMDGPU/GlobalISel: Fix selection of 16-bit shifts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373945 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 19:10:44 +00:00
Matt Arsenault a27f45d898 AMDGPU/GlobalISel: Select VALU G_AMDGPU_FFBH_U32
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373944 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 19:10:43 +00:00
Matt Arsenault 80d65f2e3a AMDGPU/GlobalISel: Use S_MOV_B64 for inline constants
This hides some defects in SIFoldOperands when the immediates are
split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373943 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 19:07:19 +00:00
Matt Arsenault d445793c39 AMDGPU/GlobalISel: Widen 16-bit G_MERGE_VALUEs sources
Continue making a mess of merge/unmerge legality.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373942 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 19:05:58 +00:00
Matt Arsenault edbb230b91 AMDGPU/GlobalISel: Select more G_INSERT cases
At minimum handle the s64 insert type, which are emitted in real cases
during legalization.

We really need TableGen to emit something to emit something like the
inverse of composeSubRegIndices do determine the subreg index to use.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373938 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 18:43:31 +00:00
Matt Arsenault b4bef9ad2f GlobalISel: Add target pre-isel instructions
Allows targets to introduce regbankselectable
pseudo-instructions. Currently the closet feature to this is an
intrinsic. However this requires creating a public intrinsic
declaration. This litters the public intrinsic namespace with
operations we don't necessarily want to expose to IR producers, and
would rather leave as private to the backend.

Use a new instruction bit. A previous attempt tried to keep using enum
value ranges, but it turned into a mess.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373937 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 18:43:29 +00:00
Jay Foad 7509fd2083 [AMDGPU] Fix test checks
The GFX10-DENORM-STRICT checks were only passing by accident. Fix them
to make the test more robust in the face of scheduling or register
allocation changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373893 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07 10:57:41 +00:00
Matt Arsenault c8e8fe1934 AMDGPU/GlobalISel: RegBankSelect DS GWS intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373840 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-06 01:37:38 +00:00
Matt Arsenault 9ab5b297df AMDGPU/GlobalISel: Lower G_ATOMIC_CMPXCHG_WITH_SUCCESS
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373839 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-06 01:37:37 +00:00
Matt Arsenault 97454bf24b GlobalISel: Partially implement lower for G_EXTRACT
Turn into shift and truncate. Doesn't yet handle pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373838 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-06 01:37:35 +00:00
Matt Arsenault 1c6d4fc3e0 AMDGPU/GlobalISel: Fix RegBankSelect for sendmsg intrinsics
This wasn't updated for the immarg handling change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373837 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-06 01:37:34 +00:00
Matt Arsenault c15d04b5f6 AMDGPU/GlobalISel: Fix using wrong addrspace for aperture
This was always passing the destination flat address space, when it
should be picking between the two valid source options.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373716 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04 08:35:38 +00:00
Matt Arsenault 9556f6366c AMDGPU/GlobalISel: Select G_PTRTOINT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373715 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04 08:35:37 +00:00
Matt Arsenault 0e704fab6e AMDGPU/GlobalISel: Support wave32 waterfall loops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373714 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04 08:35:35 +00:00
Matt Arsenault 204eb4858d AMDGPU/GlobalISel: Handle RegBankSelect of G_INSERT_VECTOR_ELT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373639 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03 17:59:03 +00:00
Matt Arsenault 793d83708f AMDGPU/GlobalISel: Split 64-bit vector extracts during RegBankSelect
Register indexing 64-bit elements is possible on the SALU, but not the
VALU. Handle splitting this into two 32-bit indexes. Extend waterfall
loop handling to allow moving a range of instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373638 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03 17:55:27 +00:00
Matt Arsenault bde9662fef AMDGPU/GlobalISel: Allow VGPR to index SGPR register
We can still do a waterfall loop over the index if using a VGPR to
index an SGPR. The result will still be a VGPR, but we can avoid the
wide copy of the source register to a VGPR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373637 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03 17:50:32 +00:00
Matt Arsenault 5e7be8b1bc AMDGPU/GlobalISel: Add some more tests for G_INSERT legalization
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03 17:50:31 +00:00
Matt Arsenault 0e53d95ce4 AMDGPU/GlobalISel: Fix mutationIsSane assert v8s8 and
This would try to do FewerElements to v9s8

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373635 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03 17:50:29 +00:00
Matt Arsenault 118db2620f AMDGPU/GlobalISel: Expand G_BITCAST legality
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373567 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03 05:46:08 +00:00
Stanislav Mekhanoshin 60eeded1a4 [AMDGPU] Fix illegal agpr use by VALU
When SIFixSGPRCopies attempts to fix an illegal copy from vector to
scalar register it calls moveToVALU(). A copy from an agpr to sgpr
becomes a copy from agpr to agpr, which may result in the illegal
register class at a use of this copy.

Solution is to copy it always into a vgpr. This may result in a
subsequent copy into an agpr if that is what really needed, however
should not happen too often and likely will be folded later.

The opposite situation may not happen because an sgpr is always
illegal where agpr is legal, so such user instructions may not
exist.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373544 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 23:23:46 +00:00
Piotr Sobczak 8db4d72fa5 [AMDGPU] Extend buffer intrinsics with swizzling
Summary:
Extend cachepolicy operand in the new VMEM buffer intrinsics
to supply information whether the buffer data is swizzled.
Also, propagate this information to MIR.

Intrinsics updated:
int_amdgcn_raw_buffer_load
int_amdgcn_raw_buffer_load_format
int_amdgcn_raw_buffer_store
int_amdgcn_raw_buffer_store_format
int_amdgcn_raw_tbuffer_load
int_amdgcn_raw_tbuffer_store
int_amdgcn_struct_buffer_load
int_amdgcn_struct_buffer_load_format
int_amdgcn_struct_buffer_store
int_amdgcn_struct_buffer_store_format
int_amdgcn_struct_tbuffer_load
int_amdgcn_struct_tbuffer_store

Furthermore, disable merging of VMEM buffer instructions
in SI Load/Store optimizer, if the "swizzled" bit on the instruction
is on.

The default value of the bit is 0, meaning that data in buffer
is linear and buffer instructions can be merged.

There is no difference in the generated code with this commit.
However, in the future it will be expected that front-ends
use buffer intrinsics with correct "swizzled" bit set.

Reviewers: arsenm, nhaehnle, tpr

Reviewed By: nhaehnle

Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, arphaman, jfb, Petar.Avramovic, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373491 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 17:22:36 +00:00
Matt Arsenault 65c0907e68 AMDGPU/GlobalISel: Assume VGPR for G_FRAME_INDEX
In principle this should behave as any other constant. However
eliminateFrameIndex currently assumes a VALU use and uses a vector
shift. Work around this by selecting to VGPR for now until
eliminateFrameIndex is fixed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373415 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 01:02:24 +00:00
Matt Arsenault addd7f5bb6 AMDGPU/GlobalISel: Private loads always use VGPRs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373414 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 01:02:21 +00:00
Matt Arsenault 8899bbd753 AMDGPU/GlobalISel: Legalize 1024-bit G_BUILD_VECTOR
This will be needed to support AGPR operations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373413 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 01:02:18 +00:00
Matt Arsenault db73d795b0 AMDGPU/GlobalISel: Fix RegBankSelect for 1024-bit values
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373412 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 01:02:14 +00:00
Stanislav Mekhanoshin e2995cfed4 [AMDGPU] separate accounting for agprs
Account and report agprs separately on gfx908. Other targets
do not change the reporting.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373411 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02 00:26:58 +00:00
Changpeng Fang 5165c118c2 AMDGPU: Fix an out of date assert in addressing FrameIndex
Reviewers:
  arsenm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373404 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 23:07:14 +00:00
Matt Arsenault 8ec8c66e71 AMDGPU/GlobalISel: Increase max legal size to 1024
There are 1024 bit register classes defined for AGPRs. Additionally
OpenCL defines vectors up to 16 x i64, and this helps those tests
legalize.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373350 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 16:35:06 +00:00
Dmitri Gribenko 30e86caa76 Revert "GlobalISel: Handle llvm.read_register"
This reverts commit r373294. It broke Clang's
CodeGen/arm64-microsoft-status-reg.cpp:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/18483

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373310 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 08:24:01 +00:00
Matt Arsenault 1346fe80b5 AMDGPU/GlobalISel: Select s1 src G_SITOFP/G_UITOFP
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373298 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 02:23:20 +00:00
Matt Arsenault cbd0775331 AMDGPU/GlobalISel: Add support for init.exec intrinsics
TThe existing wave32 behavior seems broken and incomplete, but this
reproduces it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373296 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 02:07:25 +00:00
Matt Arsenault af5c54f584 GlobalISel: Handle llvm.read_register
SelectionDAG has a bunch of machinery to defer this to selection time
for some reason. Just directly emit a copy during IRTranslator. The
x86 usage does somewhat questionably check hasFP, which could depend
on the whole function being at minimum translated.

This does lose the convergent bit if the callsite had it, which may be
a problem. We also lose that in general for intrinsics, which may also
be a problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373294 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 02:07:16 +00:00
Matt Arsenault 900bd7250e AMDGPU/GlobalISel: Avoid creating shift of 0 in arg lowering
This is sort of papering over the fact that we don't run a combiner
anywhere, but avoiding creating 2 instructions in the first place is
easy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373293 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 01:44:46 +00:00
Matt Arsenault 1c6b68965a AMDGPU/GlobalISel: Select G_UADDO/G_USUBO
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373288 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 01:23:13 +00:00
Matt Arsenault fa3f3e76a0 GlobalISel: Implement widenScalar for G_SITOFP/G_UITOFP sources
Legalize 16-bit G_SITOFP/G_UITOFP for AMDGPU.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373287 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 01:06:48 +00:00
Matt Arsenault c58403f341 AMDGPU/GlobalISel: Legalize G_GLOBAL_VALUE
Handle other cases besides LDS. Mostly a straight port of the existing
handling, without the intermediate custom nodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373286 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01 01:06:43 +00:00
Alexander Timofeev 864a620db8 [AMDGPU] SIFoldOperands should not fold register acrocc the EXEC definition
Reviewers: rampitec

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373221 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-30 15:31:17 +00:00
Roger Ferrer Ibanez ca6e7338d6 [TargetLowering] Simplify expansion of S{ADD,SUB}O
ISD::SADDO uses the suggested sequence described in the section §2.4 of
the RISCV Spec v2.2. ISD::SSUBO uses the dual approach but checking for
(non-zero) positive.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373187 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-30 07:58:50 +00:00
Matt Arsenault fe518bfae1 AMDGPU/GlobalISel: Fix select for v2s16 and/or/xor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373180 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-30 06:31:30 +00:00
Stanislav Mekhanoshin 336dc6d0e8 [AMDGPU] Improve fma.f64 test. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372908 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-25 18:50:34 +00:00
Stanislav Mekhanoshin 6edc006701 [AMDGPU] gfx10 v_fmac_f16 operand folding
Fold immediates into v_fmac_f16.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372906 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-25 18:40:20 +00:00