[PATCH] D65604: AMDGPU/GlobalISel: Alternative mappings for constants
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 13:09:26 PDT 2019
arsenm created this revision.
arsenm added reviewers: tstellar, nhaehnle.
Herald added subscribers: Petar.Avramovic, t-tye, tpr, dstuttard, rovka, yaxunl, wdng, jvesely, kzhuravl.
Without context we assume SGPR. Allowing VGPR constants theoretically
helps avoid a copy. This seems to not actually work now, and the
choice isn't based on the use bank.
https://reviews.llvm.org/D65604
Files:
lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
test/CodeGen/AMDGPU/GlobalISel/regbankselect-constant.mir
Index: test/CodeGen/AMDGPU/GlobalISel/regbankselect-constant.mir
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/GlobalISel/regbankselect-constant.mir
@@ -0,0 +1,34 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -mcpu=hawaii -run-pass=regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s
+# RUN: llc -march=amdgcn -mcpu=hawaii -run-pass=regbankselect -regbankselect-greedy -verify-machineinstrs -o - %s | FileCheck %s
+
+# FIXME: The constant bank should have been chosen as VGPR
+---
+name: test_constant_s32_vgpr_use
+legalized: true
+body: |
+ bb.0:
+ liveins: $vgpr0_vgpr1
+ ; CHECK-LABEL: name: test_constant_s32_vgpr_use
+ ; CHECK: [[COPY:%[0-9]+]]:vgpr(p1) = COPY $vgpr0_vgpr1
+ ; CHECK: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 1
+ ; CHECK: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32)
+ ; CHECK: G_STORE [[COPY1]](s32), [[COPY]](p1) :: (store 4)
+ %0:_(p1) = COPY $vgpr0_vgpr1
+ %1:_(s32) = G_CONSTANT i32 1
+ G_STORE %1, %0 :: (store 4)
+
+...
+
+---
+name: test_constant_s32_sgpr_use
+legalized: true
+body: |
+ bb.0:
+ ; CHECK-LABEL: name: test_constant_s32_sgpr_use
+ ; CHECK: [[C:%[0-9]+]]:sgpr(s32) = G_CONSTANT i32 1
+ ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.s.sendmsg), 0, [[C]](s32)
+ %0:_(s32) = G_CONSTANT i32 1
+ G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.s.sendmsg), 0, %0
+
+...
Index: lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -192,7 +192,8 @@
Operands[I] = AMDGPU::getValueMapping(AMDGPU::VGPRRegBankID, SizeI);
}
- unsigned MappingID = 0;
+ // getInstrMapping's default mapping uses ID 1, so start at 2.
+ unsigned MappingID = 2;
for (const auto &Entry : Table) {
for (unsigned I = 0; I < NumOps; ++I) {
int OpIdx = RegSrcOpIdx[I];
@@ -337,6 +338,17 @@
InstructionMappings AltMappings;
switch (MI.getOpcode()) {
+ case TargetOpcode::G_CONSTANT:
+ case TargetOpcode::G_FCONSTANT:
+ case TargetOpcode::G_FRAME_INDEX:
+ case TargetOpcode::G_GLOBAL_VALUE: {
+ static const OpRegBankEntry<1> Table[2] = {
+ { { AMDGPU::VGPRRegBankID }, 1 },
+ { { AMDGPU::SGPRRegBankID }, 1 }
+ };
+
+ return addMappingFromTable<1>(MI, MRI, { 0 }, Table);
+ }
case TargetOpcode::G_AND:
case TargetOpcode::G_OR:
case TargetOpcode::G_XOR: {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65604.212894.patch
Type: text/x-patch
Size: 2612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190801/d0856680/attachment-0001.bin>
More information about the llvm-commits
mailing list