From: Matt Arsenault Date: Tue, 10 Sep 2019 16:42:37 +0000 (+0000) Subject: AMDGPU/GlobalISel: RegBankSelect for G_ZEXTLOAD/G_SEXTLOAD X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c1da931e78953c00357c5e411b267d00c3acfdd;p=llvm AMDGPU/GlobalISel: RegBankSelect for G_ZEXTLOAD/G_SEXTLOAD git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371536 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index ff292f5c196..aa65fb6f990 100644 --- a/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -780,7 +780,9 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_, {S32, LocalPtr, 8, 8}, {S32, LocalPtr, 16, 16}, {S32, PrivatePtr, 8, 8}, - {S32, PrivatePtr, 16, 16}}); + {S32, PrivatePtr, 16, 16}, + {S32, ConstantPtr, 8, 8}, + {S32, ConstantPtr, 16, 2 * 8}}); if (ST.hasFlatAddressSpace()) { ExtLoads.legalForTypesWithMemDesc( {{S32, FlatPtr, 8, 8}, {S32, FlatPtr, 16, 16}}); diff --git a/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp index c5ec496c4ed..60f0d37982f 100644 --- a/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp +++ b/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp @@ -421,7 +421,9 @@ AMDGPURegisterBankInfo::getInstrAlternativeMappings( AltMappings.push_back(&VSMapping); break; } - case TargetOpcode::G_LOAD: { + case TargetOpcode::G_LOAD: + case TargetOpcode::G_ZEXTLOAD: + case TargetOpcode::G_SEXTLOAD: { unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, *TRI); LLT PtrTy = MRI.getType(MI.getOperand(1).getReg()); unsigned PtrSize = PtrTy.getSizeInBits(); @@ -1427,7 +1429,9 @@ void AMDGPURegisterBankInfo::applyMappingImpl( } break; } - case AMDGPU::G_LOAD: { + case AMDGPU::G_LOAD: + case AMDGPU::G_ZEXTLOAD: + case AMDGPU::G_SEXTLOAD: { if (applyMappingWideLoad(MI, OpdMapper, MRI)) return; break; @@ -2321,6 +2325,8 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const { } case AMDGPU::G_LOAD: + case AMDGPU::G_ZEXTLOAD: + case AMDGPU::G_SEXTLOAD: return getInstrMappingForLoad(MI); case AMDGPU::G_ATOMICRMW_XCHG: diff --git a/test/CodeGen/AMDGPU/GlobalISel/regbankselect-sextload.mir b/test/CodeGen/AMDGPU/GlobalISel/regbankselect-sextload.mir new file mode 100644 index 00000000000..70857f8a91c --- /dev/null +++ b/test/CodeGen/AMDGPU/GlobalISel/regbankselect-sextload.mir @@ -0,0 +1,98 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -march=amdgcn -run-pass=regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s +# RUN: llc -march=amdgcn -run-pass=regbankselect -regbankselect-greedy -verify-machineinstrs -o - %s | FileCheck %s + +--- +name: sextload_constant_i8_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + ; CHECK-LABEL: name: sextload_constant_i8_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[SEXTLOAD:%[0-9]+]]:vgpr(s32) = G_SEXTLOAD [[COPY1]](p4) :: (load 1, addrspace 4) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_SEXTLOAD %0 :: (load 1, addrspace 4, align 1) +... + +--- +name: sextload_global_i8_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + + ; CHECK-LABEL: name: sextload_global_i8_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[SEXTLOAD:%[0-9]+]]:vgpr(s32) = G_SEXTLOAD [[COPY1]](p4) :: (load 1, addrspace 1) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_SEXTLOAD %0 :: (load 1, addrspace 1, align 1) +... + +--- +name: sextload_constant_i16_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + + ; CHECK-LABEL: name: sextload_constant_i16_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[SEXTLOAD:%[0-9]+]]:vgpr(s32) = G_SEXTLOAD [[COPY1]](p4) :: (load 2, addrspace 4) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_SEXTLOAD %0 :: (load 2, addrspace 4, align 2) +... + +--- +name: sextload_global_i16_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + + ; CHECK-LABEL: name: sextload_global_i16_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[SEXTLOAD:%[0-9]+]]:vgpr(s32) = G_SEXTLOAD [[COPY1]](p4) :: (load 2, addrspace 1) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_SEXTLOAD %0 :: (load 2, addrspace 1, align 2) +... + +--- +name: sextload_local_i8_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0 + ; CHECK-LABEL: name: sextload_local_i8_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p3) = COPY $sgpr0 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p3) = COPY [[COPY]](p3) + ; CHECK: [[SEXTLOAD:%[0-9]+]]:vgpr(s32) = G_SEXTLOAD [[COPY1]](p3) :: (load 1, addrspace 3) + %0:_(p3) = COPY $sgpr0 + %1:_(s32) = G_SEXTLOAD %0 :: (load 1, addrspace 3, align 1) +... + +--- +name: sextload_local_i16_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0 + + ; CHECK-LABEL: name: sextload_local_i16_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p3) = COPY $sgpr0 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p3) = COPY [[COPY]](p3) + ; CHECK: [[SEXTLOAD:%[0-9]+]]:vgpr(s32) = G_SEXTLOAD [[COPY1]](p3) :: (load 2, addrspace 3) + %0:_(p3) = COPY $sgpr0 + %1:_(s32) = G_SEXTLOAD %0 :: (load 2, addrspace 3, align 2) +... +! diff --git a/test/CodeGen/AMDGPU/GlobalISel/regbankselect-zextload.mir b/test/CodeGen/AMDGPU/GlobalISel/regbankselect-zextload.mir new file mode 100644 index 00000000000..3ace0d3610d --- /dev/null +++ b/test/CodeGen/AMDGPU/GlobalISel/regbankselect-zextload.mir @@ -0,0 +1,97 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -march=amdgcn -run-pass=regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s +# RUN: llc -march=amdgcn -run-pass=regbankselect -regbankselect-greedy -verify-machineinstrs -o - %s | FileCheck %s + +--- +name: zextload_constant_i8_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + ; CHECK-LABEL: name: zextload_constant_i8_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[ZEXTLOAD:%[0-9]+]]:vgpr(s32) = G_ZEXTLOAD [[COPY1]](p4) :: (load 1, addrspace 4) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_ZEXTLOAD %0 :: (load 1, addrspace 4, align 1) +... + +--- +name: zextload_global_i8_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + + ; CHECK-LABEL: name: zextload_global_i8_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[ZEXTLOAD:%[0-9]+]]:vgpr(s32) = G_ZEXTLOAD [[COPY1]](p4) :: (load 1, addrspace 1) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_ZEXTLOAD %0 :: (load 1, addrspace 1, align 1) +... + +--- +name: zextload_constant_i16_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + + ; CHECK-LABEL: name: zextload_constant_i16_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[ZEXTLOAD:%[0-9]+]]:vgpr(s32) = G_ZEXTLOAD [[COPY1]](p4) :: (load 2, addrspace 4) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_ZEXTLOAD %0 :: (load 2, addrspace 4, align 2) +... + +--- +name: zextload_global_i16_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + + ; CHECK-LABEL: name: zextload_global_i16_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p4) = COPY [[COPY]](p4) + ; CHECK: [[ZEXTLOAD:%[0-9]+]]:vgpr(s32) = G_ZEXTLOAD [[COPY1]](p4) :: (load 2, addrspace 1) + %0:_(p4) = COPY $sgpr0_sgpr1 + %1:_(s32) = G_ZEXTLOAD %0 :: (load 2, addrspace 1, align 2) +... + +--- +name: zextload_local_i8_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0 + ; CHECK-LABEL: name: zextload_local_i8_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p3) = COPY $sgpr0 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p3) = COPY [[COPY]](p3) + ; CHECK: [[ZEXTLOAD:%[0-9]+]]:vgpr(s32) = G_ZEXTLOAD [[COPY1]](p3) :: (load 1, addrspace 3) + %0:_(p3) = COPY $sgpr0 + %1:_(s32) = G_ZEXTLOAD %0 :: (load 1, addrspace 3, align 1) +... + +--- +name: zextload_local_i16_to_i32_uniform +legalized: true + +body: | + bb.0: + liveins: $sgpr0 + + ; CHECK-LABEL: name: zextload_local_i16_to_i32_uniform + ; CHECK: [[COPY:%[0-9]+]]:sgpr(p3) = COPY $sgpr0 + ; CHECK: [[COPY1:%[0-9]+]]:vgpr(p3) = COPY [[COPY]](p3) + ; CHECK: [[ZEXTLOAD:%[0-9]+]]:vgpr(s32) = G_ZEXTLOAD [[COPY1]](p3) :: (load 2, addrspace 3) + %0:_(p3) = COPY $sgpr0 + %1:_(s32) = G_ZEXTLOAD %0 :: (load 2, addrspace 3, align 2) +...