[PATCH] D58804: AMDGPU/GlobalISel: Implement select for 32-bit G_ADD
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 28 17:31:56 PST 2019
tstellar created this revision.
tstellar added a reviewer: arsenm.
Herald added subscribers: Petar.Avramovic, t-tye, tpr, dstuttard, kristof.beyls, rovka, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
Herald added a project: LLVM.
Repository:
rL LLVM
https://reviews.llvm.org/D58804
Files:
lib/Target/AMDGPU/AMDGPUGISel.td
lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
test/CodeGen/AMDGPU/GlobalISel/inst-select-add.mir
Index: test/CodeGen/AMDGPU/GlobalISel/inst-select-add.mir
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/GlobalISel/inst-select-add.mir
@@ -0,0 +1,40 @@
+# RUN: llc -march=amdgcn -run-pass=instruction-select -verify-machineinstrs -global-isel %s -o - | FileCheck %s -check-prefixes=GCN
+
+---
+name: add
+legalized: true
+regBankSelected: true
+
+# GCN-LABEL: name: add
+body: |
+ bb.0:
+ liveins: $sgpr0, $sgpr1, $vgpr0, $vgpr3_vgpr4
+ ; GCN: [[SGPR0:%[0-9]+]]:sreg_32 = COPY $sgpr0
+ ; GCN: [[SGPR1:%[0-9]+]]:sreg_32 = COPY $sgpr1
+ ; GCN: [[VGPR0:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+ %0:sgpr(s32) = COPY $sgpr0
+ %1:sgpr(s32) = COPY $sgpr1
+ %2:vgpr(s32) = COPY $vgpr0
+ %3:vgpr(p1) = COPY $vgpr3_vgpr4
+ %4:sgpr(s32) = G_CONSTANT i32 1
+ %5:sgpr(s32) = G_CONSTANT i32 4096
+
+ ; add ss
+ ; GCN: [[SS:%[0-9]+]]:sreg_32_xm0 = S_ADD_I32 [[SGPR0]], [[SGPR1]]
+ %6:sgpr(s32) = G_ADD %0, %1
+
+ ; add vs
+ ; GCN: [[VS:%[0-9]+]]:vgpr_32 = V_ADD_I32_e32 [[SS]], [[VGPR0]]
+ %7:vgpr(s32) = G_ADD %2, %6
+
+ ; add sv
+ ; GCN: [[SV:%[0-9]+]]:vgpr_32 = V_ADD_I32_e32 [[SS]], [[VS]]
+ %8:vgpr(s32) = G_ADD %6, %7
+
+ ; add vv
+ ; GCN: [[VV:%[0-9]+]]:vgpr_32 = V_ADD_I32_e32 [[SV]], [[VGPR0]]
+ %9:vgpr(s32) = G_ADD %8, %2
+
+ G_STORE %9, %3 :: (store 4, addrspace 1)
+
+...
Index: lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -549,10 +549,12 @@
}
switch (I.getOpcode()) {
+ case TargetOpcode::G_ADD:
+ if (selectG_ADD(I))
+ return true;
+ LLVM_FALLTHROUGH;
default:
return selectImpl(I, CoverageInfo);
- case TargetOpcode::G_ADD:
- return selectG_ADD(I);
case TargetOpcode::G_INTTOPTR:
case TargetOpcode::G_BITCAST:
return selectCOPY(I);
Index: lib/Target/AMDGPU/AMDGPUGISel.td
===================================================================
--- lib/Target/AMDGPU/AMDGPUGISel.td
+++ lib/Target/AMDGPU/AMDGPUGISel.td
@@ -128,6 +128,9 @@
def : GISelSop2Pat <or, S_OR_B32, i32>;
def : GISelVop2Pat <or, V_OR_B32_e32, i32>;
+def : GISelSop2Pat <add, S_ADD_I32, i32>;
+def : GISelVop2Pat <add, V_ADD_I32_e32, i32>;
+
def : GISelSop2Pat <sra, S_ASHR_I32, i32>;
let AddedComplexity = 100 in {
let SubtargetPredicate = isGFX6GFX7 in {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58804.188821.patch
Type: text/x-patch
Size: 2493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190301/d4824927/attachment.bin>
More information about the llvm-commits
mailing list