3668 Commits

Author SHA1 Message Date
Jay Foad
a647751288 [AMDGPU] Optimize atomic AND/OR/XOR
Summary: Extend the atomic optimizer to handle AND, OR and XOR.

Reviewers: arsenm, sheredom

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366323 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-17 13:40:03 +00:00
Nicolai Haehnle
4e75329928 AMDGPU/GFX10: Apply the VMEM-to-scalar-write hazard also to writes to EXEC
Summary: Change-Id: I854fbf7d48e937bef9f8f3f5d0c8aeb970652630

Reviewers: rampitec, mareko

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

Tags: #llvm

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

Change-Id: I4405b3a7f84186acea5a78d291bff71056e745fc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366314 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-17 11:22:57 +00:00
Nicolai Haehnle
02e27620a4 AMDGPU: Improve alias analysis for GDS
Summary: GDS cannot alias anything else.

Original patch by: Marek Olšák

Reviewers: arsenm, mareko

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

Tags: #llvm

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

Change-Id: I07bfbd96f5d5c37a6dfba7997df12f291dd794b0

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366313 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-17 11:22:19 +00:00
Stanislav Mekhanoshin
5c4fe3f66d [AMDGPU] Autogenerate register asm names
Differential Revision: https://reviews.llvm.org/D64839

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366283 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 23:44:21 +00:00
Matt Arsenault
c46779dac2 AMDGPU/GlobalISel: Select G_ASHR
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366257 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 20:31:25 +00:00
Matt Arsenault
81598fb771 AMDGPU/GlobalISel: Select G_LSHR
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366256 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 20:25:43 +00:00
Matt Arsenault
65c12193d0 AMDGPU/GlobalISel: Select G_SHL
I think this manages to not break the DAG handling with the divergent
predicates because the stadalone divergent patterns end up with a
higher priority than the pattern on the instruction definition.

The 16-bit versions don't work yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366254 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 20:15:30 +00:00
Stanislav Mekhanoshin
10f786ca0f [AMDGPU] Change register type for v32 vectors
When it is AReg_1024 this results in unnecessary copying into
AGPRs of a 32 element vectors even though they are not intended
for an mfma instruction.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366252 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 20:06:00 +00:00
Matt Arsenault
edeaa0dc91 AMDGPU/GlobalISel: Fix selection of private stores
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366249 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 19:27:44 +00:00
Matt Arsenault
c7d2de0c8f AMDGPU/GlobalISel: Select private loads
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366248 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 19:22:21 +00:00
Matt Arsenault
329f885366 AMDGPU/GlobalISel: Select flat stores
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366246 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 18:42:53 +00:00
Matt Arsenault
b7630c7ccf AMDGPU: Add register classes to flat store patterns
For some reason GlobalISelEmitter needs register classes to import
these, although it works for the load patterns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366242 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 18:26:42 +00:00
Matt Arsenault
8daa536902 AMDGPU: Replace store PatFrags
Convert the easy cases to formats understood for GlobalISel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366240 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 18:21:25 +00:00
Matt Arsenault
b18edea81b AMDGPU/GlobalISel: Select flat loads
Now that the patterns use the new PatFrag address space support, the
only blocker to importing most load patterns is the addressing mode
complex patterns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366237 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 18:05:29 +00:00
Jay Foad
7935774fce [AMDGPU] Optimize atomic max/min
Summary:
Extend the atomic optimizer to handle signed and unsigned max and min
operations, as well as add and subtract.

Reviewers: arsenm, sheredom, critson, rampitec

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366235 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 17:44:54 +00:00
Matt Arsenault
81c5f01f3a AMDGPU: Redefine load PatFrags
Rewrite PatFrags using the new PatFrag address space matching in
tablegen. These will now work with both SelectionDAG and GlobalISel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366234 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 17:38:50 +00:00
Michael Liao
e67155b002 [AMDGPU] Add the adjusted FP as a livein register.
Reviewers: arsenm, rampitec

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366223 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 15:57:12 +00:00
Matt Arsenault
aeefee98c1 AMDGPU/GlobalISel: Fix test failures in release build
Apparently the check for legal instructions during instruction
select does not happen without an asserts build, so these would
successfully select in release, and fail in debug.

Make s16 and/or/xor legal. These can just be selected directly
to the 32-bit operation, as is already done in SelectionDAG, so just
make them legal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366210 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 14:28:30 +00:00
Rui Ueyama
c3f211d97b Fix parameter name comments using clang-tidy. NFC.
This patch applies clang-tidy's bugprone-argument-comment tool
to LLVM, clang and lld source trees. Here is how I created this
patch:

$ git clone https://github.com/llvm/llvm-project.git
$ cd llvm-project
$ mkdir build
$ cd build
$ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \
    -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \
    -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm
$ ninja
$ parallel clang-tidy -checks='-*,bugprone-argument-comment' \
    -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \
    ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h}

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366177 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 04:46:31 +00:00
Matt Arsenault
48a2462687 AMDGPU: Avoid code predicates for extload PatFrags
Use the MemoryVT field. This will be necessary for tablegen to
automatically handle patterns for GlobalISel.

Doesn't handle the d16 lo/hi patterns. Those are a special case since
it involvess the custom node type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366168 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 02:46:05 +00:00
Austin Kerbow
b7cef668c0 [AMDGPU] Enable merging m0 initializations.
Summary:
Enable hoisting and merging m0 defs that are initialized with the same
immediate value. Fixes bug where removed instructions are not considered
to interfere with other inits, and make sure to not hoist inits before block
prologues.

Reviewers: rampitec, arsenm

Reviewed By: rampitec

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366135 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 22:07:05 +00:00
Matt Arsenault
48a97c0af4 AMDGPU: Use standalone MUBUF load patterns
We already do this for the flat and DS instructions, although it is
certainly uglier and more verbose.

This will allow using separate pattern definitions for extload and
zextload. Currently we get away with using a single PatFrag with
custom predicate code to check if the extension type is a zextload or
anyextload. The generic mechanism the global isel emitter understands
treats these as mutually exclusive. I was considering making the
pattern emitter accept zextload or sextload extensions for anyextload
patterns, but in global isel, the different extending loads have
distinct opcodes, and there is currently no mechanism for an opcode
matcher to try multiple (and there probably is very little need for
one beyond this case).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366132 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 21:41:44 +00:00
Matt Arsenault
a985f4ba15 AMDGPU/GlobalISel: Allow scalar s1 and/or/xor
If a 1-bit value is in a 32-bit VGPR, the scalar opcodes set SCC to
whether the result is 0. If the inputs are SCC, these can be copied to
a 32-bit SGPR to produce an SCC result.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366125 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 20:20:18 +00:00
Matt Arsenault
46513b57db AMDGPU/GlobalISel: Select G_AND/G_OR/G_XOR
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366121 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:50:07 +00:00
Matt Arsenault
848db45c88 AMDGPU/GlobalISel: Don't constrain source register of VCC copies
This is a hack until I come up with a better way of dealing with the
pseudo-register banks used for boolean values. If the use instruction
constrains the register, the selector for the def instruction won't
see that the bank was VCC. A 1-bit SReg_32 is could ambiguously have
been SCCRegBank or VCCRegBank in wave32.

This is necessary to successfully select branches with and and/or/xor
condition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366120 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:48:36 +00:00
Matt Arsenault
fcd8db8a7d AMDGPU/GlobalISel: Fix selecting vcc->vcc bank copies
The extra test change is correct, although how it arrives there is a
bug that needs work. With wave32, the test for isVCC ambiguously
reports true for an SCC or VCC source. A new allocatable pseudo
register class for SCC may be necesssary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366119 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:46:48 +00:00
Matt Arsenault
0cf596c83a AMDGPU/GlobalISel: Fix not constraining result reg of copies to VCC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366118 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:45:49 +00:00
Matt Arsenault
0774fb325e AMDGPU/GlobalISel: Fix handling of sgpr (not scc bank) s1 to VCC
This was emitting a copy from a 32-bit register to a 64-bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366117 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:44:07 +00:00
Matt Arsenault
e86254e20e AMDGPU/GlobalISel: Custom legalize G_INSERT_VECTOR_ELT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366116 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:43:04 +00:00
Matt Arsenault
a00c6918e7 AMDGPU/GlobalISel: Custom legalize G_EXTRACT_VECTOR_ELT
Turn the constant cases into G_EXTRACTs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366115 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:40:59 +00:00
Matt Arsenault
2e692a0fec AMDGPU/GlobalISel: Fix G_ICMP for wave32
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366114 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 19:39:31 +00:00
Matt Arsenault
e278479622 AMDGPU/GlobalISel: Widen vector extracts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366103 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 18:31:10 +00:00
Matt Arsenault
92d1538833 AMDGPU/GlobalISel: Handle llvm.amdgcn.if.break
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366102 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 18:25:24 +00:00
Matt Arsenault
9aa5131c1d AMDGPU/GlobalISel: Select llvm.amdgcn.end.cf
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366099 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 18:18:46 +00:00
Matt Arsenault
b508009134 AMDGPU: Add 24-bit mul intrinsics
Insert these during codegenprepare.

This works around a DAG issue where generic combines eliminate the and
asserting the high bits are zero, which then exposes an unknown read
source to the mul combine. It doesn't worth the hassle of trying to
insert an AssertZext or something to try to deal with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366094 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 17:50:31 +00:00
Stanislav Mekhanoshin
73e6df357d [AMDGPU] Copy missing predicate from pseudo to real
NFC at the momemnt, needed for future commit.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366092 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 17:49:25 +00:00
Matt Arsenault
227403b223 AMDGPU/GlobalISel: Select easy cases for G_BUILD_VECTOR
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366087 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 17:26:43 +00:00
Matt Arsenault
b8c14e1e30 AMDGPU/GlobalISel: RegBankSelect for G_CONCAT_VECTORS
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366086 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 17:20:40 +00:00
Stanislav Mekhanoshin
5516a74ba0 [AMDGPU] fixed scheduler crash in gfx908
For some reason scheduler can send down an SUnit without an
instruction.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366074 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 15:34:05 +00:00
Dmitry Preobrazhensky
e201b95d1a [AMDGPU][MC][GFX9][GFX10] Added support of GET_DOORBELL message
Reviewers: artem.tamazov, arsenm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366071 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 15:12:16 +00:00
Dmitry Preobrazhensky
c0599ccec6 [AMDGPU][MC] Corrected encoding of src0 for DS_GWS_* instructions
See bug 42599: https://bugs.llvm.org/show_bug.cgi?id=42599

Reviewers: artem.tamazov, arsenm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366067 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 14:37:57 +00:00
Bill Wendling
58c22470dd Remove set but unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366041 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-15 06:35:28 +00:00
Stanislav Mekhanoshin
e06c3153d1 [AMDGPU] use v32f32 for 3 mfma intrinsics
These should really use v32f32, but were defined as v32i32
due to the lack of the v32f32 type.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365972 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 22:42:01 +00:00
Matt Arsenault
467221aa92 AMDGPU: Drop remnants of byval support for shaders
Before 2018, mesa used to use byval interchangably with inreg, which
didn't really make sense. Fix tests still using it to avoid breaking
in a future commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365953 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 20:12:17 +00:00
David Tenty
25aec8d782 Fix missing use of defined() in include guard
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365952 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 20:12:15 +00:00
Stanislav Mekhanoshin
345a37dd09 [AMDGPU] Extend MIMG opcode to 8 bits
This is NFC, but required for future commit.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365940 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 18:38:06 +00:00
Jay Foad
7f18dddc3d [AMDGPU] Fix DPP combiner check for exec modification
Summary:
r363675 changed the exec modification helper function, now called
execMayBeModifiedBeforeUse, so that if no UseMI is specified it checks
all instructions in the basic block, even beyond the last use. That
meant that the DPP combiner no longer worked in any basic block that
ended with a control flow instruction, and in particular it didn't work
on code sequences generated by the atomic optimizer.

Fix it by reinstating the old behaviour but in a new helper function
execMayBeModifiedBeforeAnyUse, and limiting the number of instructions
scanned.

Reviewers: arsenm, vpykhtin

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365910 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 15:59:40 +00:00
Jay Foad
9d92f46ab9 [AMDGPU] Restrict v_cndmask_b32 abs/neg modifiers to f32
Summary:
D64497 allowed abs/neg source modifiers on v_cndmask_b32 but it doesn't
make any sense to apply them to f16 operands; they would interpret the
bits of the value as an f32, giving nonsensical results. This patch
restricts them to f32 operands.

Reviewers: arsenm, hakzsam

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365904 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 15:02:59 +00:00
Fangrui Song
727b16e096 Delete dead stores
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365903 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12 14:58:15 +00:00
Michael Liao
44212f4ac8 [AMDGPU] Skip calculating callee saved registers for entry function.
Reviewers: arsenm

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365846 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-11 23:53:30 +00:00