Module: Mesa Branch: master Commit: 70ff262cda8a8e3566f73afec669386ddb4fa70c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70ff262cda8a8e3566f73afec669386ddb4fa70c
Author: Rhys Perry <[email protected]> Date: Fri Oct 16 13:18:08 2020 +0100 aco: use v_mov_b32_sdwa for some 16-bit constants Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Timur Kristóf <[email protected]> Reviewed-by: Daniel Schürmann <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7216> --- src/amd/compiler/aco_lower_to_hw_instr.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp index 8c6766b17c8..f7a401209e1 100644 --- a/src/amd/compiler/aco_lower_to_hw_instr.cpp +++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp @@ -1028,7 +1028,14 @@ void copy_constant(lower_context *ctx, Builder& bld, Definition dst, Operand op) } } else if (dst.regClass() == v2b && op.isConstant() && !op.isLiteral()) { assert(ctx->program->chip_class >= GFX8); - bld.vop2_sdwa(aco_opcode::v_add_f16, dst, op, Operand(0u)); + if (op.constantValue() >= 0xfff0 || op.constantValue() <= 64) { + /* use v_mov_b32 to avoid possible issues with denormal flushing or + * NaN. v_add_f16 is still needed for float constants. */ + uint32_t val32 = (int32_t)(int16_t)op.constantValue(); + bld.vop1_sdwa(aco_opcode::v_mov_b32, dst, Operand(val32)); + } else { + bld.vop2_sdwa(aco_opcode::v_add_f16, dst, op, Operand(0u)); + } } else if (dst.regClass() == v2b && op.isLiteral()) { if (ctx->program->chip_class < GFX10 || !(ctx->block->fp_mode.denorm16_64 & fp_denorm_keep_in)) { unsigned offset = dst.physReg().byte() * 8u; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
