From cd2f8e928324aa5540f965cb72638124a2c1dbf7 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Sat, 24 Feb 2018 01:32:32 +0000 Subject: [PATCH] [AMDGPU] Shrinking V_SUBBREV_U32 V_SUBBREV_U32 is a commute opcode for V_SUBB_U32. However, when we try to commute V_SUBB_U32 in order to shrink it we do not then process V_SUBBREV_U32 and it stay VOP3. This is fixed. Differential Revision: https://reviews.llvm.org/D43699 llvm-svn: 326011 --- lib/Target/AMDGPU/SIShrinkInstructions.cpp | 3 ++- test/CodeGen/AMDGPU/combine-cond-add-sub.ll | 8 ++++---- test/CodeGen/AMDGPU/shrink-carry.mir | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Target/AMDGPU/SIShrinkInstructions.cpp b/lib/Target/AMDGPU/SIShrinkInstructions.cpp index 41f989ad322..994658dd3f8 100644 --- a/lib/Target/AMDGPU/SIShrinkInstructions.cpp +++ b/lib/Target/AMDGPU/SIShrinkInstructions.cpp @@ -92,7 +92,8 @@ static bool canShrink(MachineInstr &MI, const SIInstrInfo *TII, case AMDGPU::V_ADDC_U32_e64: case AMDGPU::V_SUBB_U32_e64: - if (TII->getNamedOperand(MI, AMDGPU::OpName::src1)->isImm()) + case AMDGPU::V_SUBBREV_U32_e64: + if (!isVGPR(TII->getNamedOperand(MI, AMDGPU::OpName::src1), TRI, MRI)) return false; // Additional verification is needed for sdst/src2. return true; diff --git a/test/CodeGen/AMDGPU/combine-cond-add-sub.ll b/test/CodeGen/AMDGPU/combine-cond-add-sub.ll index 9e47c7d3449..f94b2fa3aa3 100644 --- a/test/CodeGen/AMDGPU/combine-cond-add-sub.ll +++ b/test/CodeGen/AMDGPU/combine-cond-add-sub.ll @@ -19,8 +19,8 @@ bb: } ; GCN-LABEL: {{^}}sub1: -; GCN: v_cmp_gt_u32_e{{32|64}} [[CC:[^,]+]], v{{[0-9]+}}, v{{[0-9]+}} -; GCN: v_subb_u32_e{{32|64}} v{{[0-9]+}}, {{[^,]+}}, v{{[0-9]+}}, 0, [[CC]] +; GCN: v_cmp_gt_u32_e32 vcc, v{{[0-9]+}}, v{{[0-9]+}} +; GCN: v_subbrev_u32_e32 v{{[0-9]+}}, vcc, 0, v{{[0-9]+}}, vcc ; GCN-NOT: v_cndmask define amdgpu_kernel void @sub1(i32 addrspace(1)* nocapture %arg) { @@ -134,8 +134,8 @@ bb: } ; GCN-LABEL: {{^}}sext_flclass: -; GCN: v_cmp_class_f32_e{{32|64}} [[CC:[^,]+]], -; GCN: v_subb_u32_e{{32|64}} v{{[0-9]+}}, {{[^,]+}}, v{{[0-9]+}}, 0, [[CC]] +; GCN: v_cmp_class_f32_e32 vcc, +; GCN: v_subbrev_u32_e32 v{{[0-9]+}}, vcc, 0, v{{[0-9]+}}, vcc ; GCN-NOT: v_cndmask define amdgpu_kernel void @sext_flclass(i32 addrspace(1)* nocapture %arg, float %x) { diff --git a/test/CodeGen/AMDGPU/shrink-carry.mir b/test/CodeGen/AMDGPU/shrink-carry.mir index 8a6c8ceae22..838a4f35626 100644 --- a/test/CodeGen/AMDGPU/shrink-carry.mir +++ b/test/CodeGen/AMDGPU/shrink-carry.mir @@ -1,7 +1,7 @@ # RUN: llc -march=amdgcn -verify-machineinstrs -start-before si-shrink-instructions -stop-before si-insert-skips -o - %s | FileCheck -check-prefix=GCN %s # GCN-LABEL: name: subbrev{{$}} -# GCN: V_SUBBREV_U32_e64 0, undef $vgpr0, killed $vcc, implicit $exec +# GCN: V_SUBBREV_U32_e32 0, undef $vgpr0, implicit-def $vcc, implicit killed $vcc, implicit $exec --- name: subbrev @@ -25,7 +25,7 @@ body: | ... # GCN-LABEL: name: subb{{$}} -# GCN: V_SUBB_U32_e64 undef $vgpr0, 0, killed $vcc, implicit $exec +# GCN: V_SUBBREV_U32_e32 0, undef $vgpr0, implicit-def $vcc, implicit killed $vcc, implicit $exec --- name: subb