[llvm] r326714 - AMDGPU/GlobalISel: Make some G_EXTRACTs legal
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 08:25:15 PST 2018
Author: arsenm
Date: Mon Mar 5 08:25:15 2018
New Revision: 326714
URL: http://llvm.org/viewvc/llvm-project?rev=326714&view=rev
Log:
AMDGPU/GlobalISel: Make some G_EXTRACTs legal
As far as I can tell legalization of weird sizes for the
output type isn't implemented.
Added:
llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp?rev=326714&r1=326713&r2=326714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp Mon Mar 5 08:25:15 2018
@@ -106,5 +106,17 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo
setAction({G_LOAD, 1, S64}, Legal);
setAction({G_STORE, 1, S64}, Legal);
+ // FIXME: Doesn't handle extract of illegal sizes.
+ getActionDefinitionsBuilder(G_EXTRACT)
+ .unsupportedIf([=](const LegalityQuery &Query) {
+ return Query.Types[0].getSizeInBits() >= Query.Types[1].getSizeInBits();
+ })
+ .legalIf([=](const LegalityQuery &Query) {
+ const LLT &Ty0 = Query.Types[0];
+ const LLT &Ty1 = Query.Types[1];
+ return (Ty0.getSizeInBits() % 32 == 0) &&
+ (Ty1.getSizeInBits() % 32 == 0);
+ });
+
computeTables();
}
Added: llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir?rev=326714&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir Mon Mar 5 08:25:15 2018
@@ -0,0 +1,105 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -run-pass=legalizer -global-isel %s -o - | FileCheck %s
+
+---
+name: test_extract_lo32_i64
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1
+
+ ; CHECK-LABEL: name: test_extract_lo32_i64
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s64), 0
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s64) = COPY $vgpr0_vgpr1
+ %1:_(s32) = G_EXTRACT %0, 0
+ S_ENDPGM implicit %1
+...
+---
+name: test_extract_hi32_i64
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1
+
+ ; CHECK-LABEL: name: test_extract_hi32_i64
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s64), 32
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s64) = COPY $vgpr0_vgpr1
+ %1:_(s32) = G_EXTRACT %0, 32
+ S_ENDPGM implicit %1
+...
+
+---
+name: test_extract_dword0_i128
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1
+
+ ; CHECK-LABEL: name: test_extract_dword0_i128
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s64), 0
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s64) = COPY $vgpr0_vgpr1
+ %1:_(s32) = G_EXTRACT %0, 0
+ S_ENDPGM implicit %1
+...
+
+---
+name: test_extract_dword1_i128
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1_vgpr2_vgpr3
+
+ ; CHECK-LABEL: name: test_extract_dword1_i128
+ ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s128), 32
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
+ %1:_(s32) = G_EXTRACT %0, 32
+ S_ENDPGM implicit %1
+...
+
+---
+name: test_extract_dword2_i128
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1_vgpr2_vgpr3
+
+ ; CHECK-LABEL: name: test_extract_dword2_i128
+ ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s128), 64
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
+ %1:_(s32) = G_EXTRACT %0, 64
+ S_ENDPGM implicit %1
+...
+
+---
+name: test_extract_dword3_i128
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1_vgpr2_vgpr3
+
+ ; CHECK-LABEL: name: test_extract_dword3_i128
+ ; CHECK: [[COPY:%[0-9]+]]:_(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s128), 96
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s128) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
+ %1:_(s32) = G_EXTRACT %0, 96
+ S_ENDPGM implicit %1
+...
+---
+name: test_extract_dword2_i96
+body: |
+ bb.0.entry:
+ liveins: $vgpr0_vgpr1_vgpr2
+
+ ; CHECK-LABEL: name: test_extract_dword2_i96
+ ; CHECK: [[COPY:%[0-9]+]]:_(s96) = COPY $vgpr0_vgpr1_vgpr2
+ ; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY]](s96), 64
+ ; CHECK: S_ENDPGM implicit [[EXTRACT]](s32)
+ %0:_(s96) = COPY $vgpr0_vgpr1_vgpr2
+ %1:_(s32) = G_EXTRACT %0, 64
+ S_ENDPGM implicit %1
+...
More information about the llvm-commits
mailing list