Mesa (main): aco: disable mul(cndmask(0, 1, b), a) optimization sometimes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 20 07:56:19 UTC 2021


Module: Mesa
Branch: main
Commit: 9bc0fc89c8909fd5cc9c591aa98038f927a01e0e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9bc0fc89c8909fd5cc9c591aa98038f927a01e0e

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Tue Oct 19 10:43:03 2021 +0100

aco: disable mul(cndmask(0, 1, b), a) optimization sometimes

This optimization doesn't work for SDWA or DPP multiplications and we
can't do it if denormal flushing is required because v_cndmask_b32 doesn't
do that and we can't do it if we can't assume operands are finite because
0.0 * inf is NaN, not 0.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13434>

---

 src/amd/compiler/aco_optimizer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp
index ad70ca15503..8d88d08e2d7 100644
--- a/src/amd/compiler/aco_optimizer.cpp
+++ b/src/amd/compiler/aco_optimizer.cpp
@@ -3453,7 +3453,8 @@ combine_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
       }
    }
    /* v_mul_f32(v_cndmask_b32(0, 1.0, cond), a) -> v_cndmask_b32(0, a, cond) */
-   else if (instr->opcode == aco_opcode::v_mul_f32 && !instr->isVOP3()) {
+   else if (instr->opcode == aco_opcode::v_mul_f32 && !ctx.fp_mode.preserve_signed_zero_inf_nan32 &&
+            !instr->usesModifiers() && !ctx.fp_mode.must_flush_denorms32) {
       for (unsigned i = 0; i < 2; i++) {
          if (instr->operands[i].isTemp() && ctx.info[instr->operands[i].tempId()].is_b2f() &&
              ctx.uses[instr->operands[i].tempId()] == 1 && instr->operands[!i].isTemp() &&



More information about the mesa-commit mailing list