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

Author: Rhys Perry <[email protected]>
Date:   Fri Jan 28 13:48:34 2022 +0000

aco: fix neg(abs(mul(a, b))) if the mul is not VOP3

Previously, is_abs was just ignored if mul_instr->isVOP3()==false.

Signed-off-by: Rhys Perry <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Fixes: 93c8ebfa780 ("aco: Initial commit of independent AMD compiler")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14773>

---

 src/amd/compiler/aco_optimizer.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/amd/compiler/aco_optimizer.cpp 
b/src/amd/compiler/aco_optimizer.cpp
index 16bab05ea00..6f08dbfe930 100644
--- a/src/amd/compiler/aco_optimizer.cpp
+++ b/src/amd/compiler/aco_optimizer.cpp
@@ -3515,12 +3515,16 @@ combine_instruction(opt_ctx& ctx, aco_ptr<Instruction>& 
instr)
       VOP3_instruction& new_mul = instr->vop3();
       if (mul_instr->isVOP3()) {
          VOP3_instruction& mul = mul_instr->vop3();
-         new_mul.neg[0] = mul.neg[0] && !is_abs;
-         new_mul.neg[1] = mul.neg[1] && !is_abs;
-         new_mul.abs[0] = mul.abs[0] || is_abs;
-         new_mul.abs[1] = mul.abs[1] || is_abs;
+         new_mul.neg[0] = mul.neg[0];
+         new_mul.neg[1] = mul.neg[1];
+         new_mul.abs[0] = mul.abs[0];
+         new_mul.abs[1] = mul.abs[1];
          new_mul.omod = mul.omod;
       }
+      if (is_abs) {
+         new_mul.neg[0] = new_mul.neg[1] = false;
+         new_mul.abs[0] = new_mul.abs[1] = true;
+      }
       new_mul.neg[0] ^= true;
       new_mul.clamp = false;
 

Reply via email to