diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td b/llvm/lib/Target/AMDGPU/SIInstrInfo.td index 403c657c64053..23a7f508dcda2 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td @@ -846,6 +846,11 @@ def cond_as_i32imm: SDNodeXForm; // Copied from the AArch64 backend: +def bitcast_fpimm_to_i16 : SDNodeXFormgetTargetConstant( + N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i16); +}]>; + def bitcast_fpimm_to_i32 : SDNodeXFormgetTargetConstant( N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32); diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td index de77401eb0137..37ce5d548dfed 100644 --- a/llvm/lib/Target/AMDGPU/SIInstructions.td +++ b/llvm/lib/Target/AMDGPU/SIInstructions.td @@ -2283,7 +2283,7 @@ let True16Predicate = UseRealTrue16Insts in { foreach vt = [f16, bf16] in { def : GCNPat < (VGPRImm<(vt fpimm)>:$imm), - (V_MOV_B16_t16_e64 0, $imm, 0) + (V_MOV_B16_t16_e64 0, (vt (bitcast_fpimm_to_i16 $imm)), 0) >; } }