diff options
| author | Tom Stellard <tstellar@redhat.com> | 2018-06-30 04:09:44 +0000 |
|---|---|---|
| committer | Tom Stellard <tstellar@redhat.com> | 2018-06-30 04:09:44 +0000 |
| commit | eebbfc2809d7d4b96c4c7040450c3171f710d5d6 (patch) | |
| tree | 1a9c7c98b5e89c9643adad0246d4f2d70b818ded /llvm | |
| parent | 8bda1881cadcd8072fd06a4440e8ad57a8a329b3 (diff) | |
| download | bcm5719-llvm-eebbfc2809d7d4b96c4c7040450c3171f710d5d6.tar.gz bcm5719-llvm-eebbfc2809d7d4b96c4c7040450c3171f710d5d6.zip | |
AMDGPU/GlobalISel: Make IMPLICIT_DEF of all sizes < 512 legal.
Summary:
We could split sizes that are not power of two into smaller sized
G_IMPLICIT_DEF instructions, but this ends up generating
G_MERGE_VALUES instructions which we then have to handle in the instruction
selector. Since G_IMPLICIT_DEF is really a no-op it's easier just to
keep everything that can fit into a register legal.
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D48777
llvm-svn: 336041
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 12 | ||||
| -rw-r--r-- | llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-implicit-def.mir | 20 |
2 files changed, 30 insertions, 2 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index 38e81de7fa1..ff16ceed6ab 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -39,6 +39,7 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const SISubtarget &ST, const LLT S32 = LLT::scalar(32); const LLT S64 = LLT::scalar(64); + const LLT S512 = LLT::scalar(512); const LLT GlobalPtr = GetAddrSpacePtr(AMDGPUAS::GLOBAL_ADDRESS); const LLT ConstantPtr = GetAddrSpacePtr(AMDGPUAS::CONSTANT_ADDRESS); @@ -70,9 +71,16 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const SISubtarget &ST, getActionDefinitionsBuilder(G_FCONSTANT) .legalFor({S32, S64}); + + // G_IMPLICIT_DEF is a no-op so we can make it legal for any value type that + // can fit in a register. + // FIXME: We need to legalize several more operations before we can add + // a test case for size > 512. getActionDefinitionsBuilder(G_IMPLICIT_DEF) - .legalFor({S1, S32, S64, - GlobalPtr, ConstantPtr, LocalPtr, FlatPtr, PrivatePtr}); + .legalIf([=](const LegalityQuery &Query) { + return Query.Types[0].getSizeInBits() <= 512; + }) + .clampScalar(0, S1, S512); getActionDefinitionsBuilder(G_CONSTANT) .legalFor({S1, S32, S64}); diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-implicit-def.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-implicit-def.mir new file mode 100644 index 00000000000..df7e40ee360 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-implicit-def.mir @@ -0,0 +1,20 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=amdgcn-mesa-mesa3d -run-pass=legalizer %s -o - | FileCheck %s + +# FIXME: Need to add test for IMPLICIT_DEF > 512 once all the operations used +# to legalize IMPLICIT_DEF are leagl. + +--- +name: test_implicit_def +body: | + bb.0: + liveins: $vgpr0, $vgpr1 + + ; CHECK-LABEL: name: test_implicit_def + ; CHECK: [[DEF:%[0-9]+]]:_(s448) = G_IMPLICIT_DEF + ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[DEF]](s448), 0 + ; CHECK: $vgpr0 = COPY [[EXTRACT]](s32) + %0:_(s448) = G_IMPLICIT_DEF + %1:_(s32) = G_EXTRACT %0, 0 + $vgpr0 = COPY %1 +... |

