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

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 2 21:21:47 UTC 2022


Module: Mesa
Branch: staging/21.3
Commit: a3f07a7c7fff56dba27c9507e967195c293734e8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3f07a7c7fff56dba27c9507e967195c293734e8

Author: Rhys Perry <pendingchaos02 at gmail.com>
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 <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Fixes: 93c8ebfa780 ("aco: Initial commit of independent AMD compiler")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14773>
(cherry picked from commit 452975f257f14ae755c713d607a002b9211a8a17)

---

 .pick_status.json                  |  2 +-
 src/amd/compiler/aco_optimizer.cpp | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b46dc4d9e92..a7346a2cccd 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1543,7 +1543,7 @@
         "description": "aco: fix neg(abs(mul(a, b))) if the mul is not VOP3",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "93c8ebfa780ebd1495095e794731881aef29e7d3"
     },
diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp
index f532f03ae96..ceeaeaea51b 100644
--- a/src/amd/compiler/aco_optimizer.cpp
+++ b/src/amd/compiler/aco_optimizer.cpp
@@ -3326,12 +3326,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;
 



More information about the mesa-commit mailing list