[llvm] r327268 - AMDGPU/GlobalISel: InstrMapping for G_MERGE_VALUES
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 12 06:35:49 PDT 2018
Author: arsenm
Date: Mon Mar 12 06:35:49 2018
New Revision: 327268
URL: http://llvm.org/viewvc/llvm-project?rev=327268&view=rev
Log:
AMDGPU/GlobalISel: InstrMapping for G_MERGE_VALUES
Added:
llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/regbankselect-merge-values.mir
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-merge-values.mir
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp?rev=327268&r1=327267&r2=327268&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp Mon Mar 12 06:35:49 2018
@@ -317,6 +317,18 @@ AMDGPURegisterBankInfo::getInstrMapping(
OpdsMapping[2] = nullptr;
break;
}
+ case AMDGPU::G_MERGE_VALUES: {
+ unsigned Bank = isSALUMapping(MI) ?
+ AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
+ unsigned DstSize = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
+ unsigned SrcSize = MRI.getType(MI.getOperand(1).getReg()).getSizeInBits();
+
+ OpdsMapping[0] = AMDGPU::getValueMapping(Bank, DstSize);
+ // Op1 and Dst should use the same register bank.
+ for (unsigned i = 1, e = MI.getNumOperands(); i != e; ++i)
+ OpdsMapping[i] = AMDGPU::getValueMapping(Bank, SrcSize);
+ break;
+ }
case AMDGPU::G_BITCAST: {
unsigned Size = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
unsigned BankID = getRegBankID(MI.getOperand(1).getReg(), MRI, *TRI);
Modified: llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-merge-values.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-merge-values.mir?rev=327268&r1=327267&r2=327268&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-merge-values.mir (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/legalize-merge-values.mir Mon Mar 12 06:35:49 2018
@@ -1,5 +1,5 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-# RUN: llc -mtriple=amdgcn-- -O0 -run-pass=legalizer -global-isel %s | FileCheck %s
+# RUN: llc -mtriple=amdgcn-- -O0 -run-pass=legalizer -global-isel -o - %s | FileCheck %s
---
name: test_merge_s32_s32_s64
Added: llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/regbankselect-merge-values.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/regbankselect-merge-values.mir?rev=327268&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/regbankselect-merge-values.mir (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/regbankselect-merge-values.mir Mon Mar 12 06:35:49 2018
@@ -0,0 +1,44 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect -global-isel %s -verify-machineinstrs -o - -regbankselect-fast | FileCheck %s
+# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect -global-isel %s -verify-machineinstrs -o - -regbankselect-greedy | FileCheck %s
+
+---
+name: merge_s32_s32_s64_s
+legalized: true
+
+body: |
+ bb.0:
+ liveins: $sgpr0, $sgpr1
+ ; CHECK-LABEL: name: merge_s32_s32_s64_s
+ ; CHECK: [[COPY:%[0-9]+]]:sgpr(s64) = COPY $sgpr0_sgpr1
+ ; CHECK: [[EXTRACT:%[0-9]+]]:sgpr(s32) = G_EXTRACT [[COPY]](s64), 0
+ ; CHECK: [[EXTRACT1:%[0-9]+]]:sgpr(s32) = G_EXTRACT [[COPY]](s64), 32
+ ; CHECK: [[MV:%[0-9]+]]:sgpr(s64) = G_MERGE_VALUES [[EXTRACT]](s32), [[EXTRACT1]](s32)
+ ; CHECK: S_ENDPGM implicit [[MV]](s64)
+ %0:_(s64) = COPY $sgpr0_sgpr1
+ %1:_(s32) = G_EXTRACT %0, 0
+ %2:_(s32) = G_EXTRACT %0, 32
+ %3:_(s64) = G_MERGE_VALUES %1, %2
+ S_ENDPGM implicit %3
+...
+
+---
+name: merge_s32_s32_s64_v
+legalized: true
+
+body: |
+ bb.0:
+ liveins: $vgpr0, $vgpr1
+ ; CHECK-LABEL: name: merge_s32_s32_s64_v
+ ; CHECK: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1
+ ; CHECK: [[EXTRACT:%[0-9]+]]:vgpr(s32) = G_EXTRACT [[COPY]](s64), 0
+ ; CHECK: [[EXTRACT1:%[0-9]+]]:vgpr(s32) = G_EXTRACT [[COPY]](s64), 32
+ ; CHECK: [[MV:%[0-9]+]]:vgpr(s64) = G_MERGE_VALUES [[EXTRACT]](s32), [[EXTRACT1]](s32)
+ ; CHECK: S_ENDPGM implicit [[MV]](s64)
+ %0:_(s64) = COPY $vgpr0_vgpr1
+ %1:_(s32) = G_EXTRACT %0, 0
+ %2:_(s32) = G_EXTRACT %0, 32
+ %3:_(s64) = G_MERGE_VALUES %1, %2
+ S_ENDPGM implicit %3
+...
+
More information about the llvm-commits
mailing list