From: Matt Arsenault Date: Mon, 5 Mar 2018 16:25:15 +0000 (+0000) Subject: AMDGPU/GlobalISel: Make some G_EXTRACTs legal X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71272e6d4eec697b0dcbc2b5e36f01bf2d0785f6;p=platform%2Fupstream%2Fllvm.git AMDGPU/GlobalISel: Make some G_EXTRACTs legal As far as I can tell legalization of weird sizes for the output type isn't implemented. llvm-svn: 326714 --- diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index adf263e..1a2b96a 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -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(); } diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir new file mode 100644 index 0000000..97cd5f0 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir @@ -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 +...