Index: lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -106,5 +106,17 @@ 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(); } Index: test/CodeGen/AMDGPU/GlobalISel/legalize-extract.mir =================================================================== --- /dev/null +++ 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 +...