aco: use v_mov_b32_sdwa for some 16-bit constants

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7216>
This commit is contained in:
Rhys Perry 2020-10-16 13:18:08 +01:00 committed by Marge Bot
parent b882598ee1
commit 70ff262cda
1 changed files with 8 additions and 1 deletions

View File

@ -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;