From 13fa3ce1bc6c5ddf8b7e49670e2f8da8f6e8cf93 Mon Sep 17 00:00:00 2001 From: Tim Renouf Date: Wed, 18 Sep 2019 09:32:06 +0000 Subject: [PATCH] [AMDGPU] Allow FP inline constant in v_madak_f16 and v_fmaak_f16 Differential Revision: https://reviews.llvm.org/D67680 Change-Id: Ic38f47cb2079c2c1070a441b5943854844d80a7c llvm-svn: 372208 --- lib/Target/AMDGPU/VOP2Instructions.td | 4 +++- test/CodeGen/AMDGPU/twoaddr-fma.mir | 20 ++++++++++++++++++++ test/CodeGen/AMDGPU/twoaddr-mad.mir | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/Target/AMDGPU/VOP2Instructions.td b/lib/Target/AMDGPU/VOP2Instructions.td index 1ed451af833..0dda9687a15 100644 --- a/lib/Target/AMDGPU/VOP2Instructions.td +++ b/lib/Target/AMDGPU/VOP2Instructions.td @@ -251,7 +251,9 @@ multiclass VOP2eInstAliases { class VOP_MADAK : VOPProfile <[vt, vt, vt, vt]> { field Operand ImmOpType = !if(!eq(vt.Size, 32), f32kimm, f16kimm); - field dag Ins32 = (ins VCSrc_f32:$src0, VGPR_32:$src1, ImmOpType:$imm); + field dag Ins32 = !if(!eq(vt.Size, 32), + (ins VCSrc_f32:$src0, VGPR_32:$src1, ImmOpType:$imm), + (ins VCSrc_f16:$src0, VGPR_32:$src1, ImmOpType:$imm)); field bit HasExt = 0; // Hack to stop printing _e64 diff --git a/test/CodeGen/AMDGPU/twoaddr-fma.mir b/test/CodeGen/AMDGPU/twoaddr-fma.mir index 52966402e8a..b0aeb91787c 100644 --- a/test/CodeGen/AMDGPU/twoaddr-fma.mir +++ b/test/CodeGen/AMDGPU/twoaddr-fma.mir @@ -181,3 +181,23 @@ body: | %1 = V_FMAC_F32_e32 %stack.0, %0, %2, implicit $exec ... + +# GCN-LABEL: name: test_fmaak_inline_literal_f16 +# GCN: %2:vgpr_32 = V_FMAAK_F16 16384, killed %0, 49664, implicit $exec + +--- +name: test_fmaak_inline_literal_f16 +liveins: + - { reg: '$vgpr0', virtual-reg: '%3' } +body: | + bb.0: + liveins: $vgpr0 + + %3:vgpr_32 = COPY killed $vgpr0 + + %26:vgpr_32 = V_MOV_B32_e32 49664, implicit $exec + %28:vgpr_32 = V_FMAC_F16_e32 16384, killed %3, %26, implicit $exec + S_ENDPGM 0 + +... + diff --git a/test/CodeGen/AMDGPU/twoaddr-mad.mir b/test/CodeGen/AMDGPU/twoaddr-mad.mir index 886785af78e..e75194bf4b8 100644 --- a/test/CodeGen/AMDGPU/twoaddr-mad.mir +++ b/test/CodeGen/AMDGPU/twoaddr-mad.mir @@ -188,3 +188,23 @@ body: | %1 = V_MAC_F32_e32 %stack.0, %0, %2, implicit $exec ... + +# GCN-LABEL: name: test_madak_inline_literal_f16 +# GCN: %2:vgpr_32 = V_MADAK_F16 16384, killed %0, 49664, implicit $exec + +--- +name: test_madak_inline_literal_f16 +liveins: + - { reg: '$vgpr0', virtual-reg: '%3' } +body: | + bb.0: + liveins: $vgpr0 + + %3:vgpr_32 = COPY killed $vgpr0 + + %26:vgpr_32 = V_MOV_B32_e32 49664, implicit $exec + %28:vgpr_32 = V_MAC_F16_e32 16384, killed %3, %26, implicit $exec + S_ENDPGM 0 + +... +