Mesa (main): aco: don't combine fneg/fabs of different bit-size
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Feb 3 16:21:09 UTC 2022
Module: Mesa
Branch: main
Commit: 7e30f99b0a783c3c9ec653e7af6d9eab1c98ea21
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e30f99b0a783c3c9ec653e7af6d9eab1c98ea21
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Mon Jan 31 18:01:45 2022 +0000
aco: don't combine fneg/fabs of different bit-size
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14810>
---
src/amd/compiler/aco_optimizer.cpp | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp
index 85701c0b70b..939551f9a6b 100644
--- a/src/amd/compiler/aco_optimizer.cpp
+++ b/src/amd/compiler/aco_optimizer.cpp
@@ -1229,13 +1229,16 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
else
can_use_mod = can_use_mod && (instr->isDPP16() || can_use_VOP3(ctx, instr));
- if (info.is_neg() && instr->opcode == aco_opcode::v_add_f32) {
+ unsigned bits = get_operand_size(instr, i);
+ bool mod_bitsize_compat = instr->operands[i].bytes() * 8 == bits;
+
+ if (info.is_neg() && instr->opcode == aco_opcode::v_add_f32 && mod_bitsize_compat) {
instr->opcode = i ? aco_opcode::v_sub_f32 : aco_opcode::v_subrev_f32;
instr->operands[i].setTemp(info.temp);
- } else if (info.is_neg() && instr->opcode == aco_opcode::v_add_f16) {
+ } else if (info.is_neg() && instr->opcode == aco_opcode::v_add_f16 && mod_bitsize_compat) {
instr->opcode = i ? aco_opcode::v_sub_f16 : aco_opcode::v_subrev_f16;
instr->operands[i].setTemp(info.temp);
- } else if (info.is_neg() && can_use_mod &&
+ } else if (info.is_neg() && can_use_mod && mod_bitsize_compat &&
can_eliminate_fcanonicalize(ctx, instr, info.temp)) {
if (!instr->isDPP() && !instr->isSDWA())
to_VOP3(ctx, instr);
@@ -1247,7 +1250,8 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
else if (instr->isVOP3() && !instr->vop3().abs[i])
instr->vop3().neg[i] = true;
}
- if (info.is_abs() && can_use_mod && can_eliminate_fcanonicalize(ctx, instr, info.temp)) {
+ if (info.is_abs() && can_use_mod && mod_bitsize_compat &&
+ can_eliminate_fcanonicalize(ctx, instr, info.temp)) {
if (!instr->isDPP() && !instr->isSDWA())
to_VOP3(ctx, instr);
instr->operands[i] = Operand(info.temp);
@@ -1265,7 +1269,6 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
continue;
}
- unsigned bits = get_operand_size(instr, i);
if (info.is_constant(bits) && alu_can_accept_constant(instr->opcode, i) &&
(!instr->isSDWA() || ctx.program->chip_class >= GFX9)) {
Operand op = get_constant_op(ctx, info, bits);
More information about the mesa-commit
mailing list