Mesa (main): pan/bi: Fuse abs into FCMP/FMIN/FMAX.v2f16

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 20:41:30 UTC 2021


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Fri Jun 11 12:43:41 2021 -0400

pan/bi: Fuse abs into FCMP/FMIN/FMAX.v2f16

Needs to be aware of an encoding restriction here.

No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11327>

---

 src/panfrost/bifrost/bi_opt_mod_props.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/panfrost/bifrost/bi_opt_mod_props.c b/src/panfrost/bifrost/bi_opt_mod_props.c
index 03888184288..628f643b20e 100644
--- a/src/panfrost/bifrost/bi_opt_mod_props.c
+++ b/src/panfrost/bifrost/bi_opt_mod_props.c
@@ -25,14 +25,14 @@
 #include "compiler.h"
 
 static bool
-bi_takes_fabs(bi_instr *I, unsigned s)
+bi_takes_fabs(bi_instr *I, bi_index repl, unsigned s)
 {
         switch (I->op) {
         case BI_OPCODE_FCMP_V2F16:
         case BI_OPCODE_FMAX_V2F16:
         case BI_OPCODE_FMIN_V2F16:
-                /* TODO: Check count or lower */
-                return false;
+                /* Encoding restriction: can't have both abs if equal sources */
+                return !(I->src[1 - s].abs && bi_is_word_equiv(I->src[1 - s], repl));
         case BI_OPCODE_V2F32_TO_V2F16:
                 /* TODO: Needs both match or lower */
                 return false;
@@ -126,7 +126,7 @@ bi_opt_mod_prop_forward(bi_context *ctx)
                                 continue;
 
                         if (bi_is_fabsneg(mod)) {
-                                if (mod->src[0].abs && !bi_takes_fabs(I, s))
+                                if (mod->src[0].abs && !bi_takes_fabs(I, mod->src[0], s))
                                         continue;
 
                                 if (mod->src[0].neg && !bi_takes_fneg(I, s))



More information about the mesa-commit mailing list