Mesa (master): vc4: Optimize the other case of SEL_X_Y wih a 0 -> SEL_X_0( a).

Eric Anholt anholt at kemper.freedesktop.org
Fri Oct 10 13:55:18 UTC 2014


Module: Mesa
Branch: master
Commit: 7c474f9f2e5e3161ad27129844139ee14d916726
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c474f9f2e5e3161ad27129844139ee14d916726

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Oct  9 09:40:51 2014 +0200

vc4: Optimize the other case of SEL_X_Y wih a 0 -> SEL_X_0(a).

Cleans up some output to be more obvious in a piglit test I'm looking at.

---

 src/gallium/drivers/vc4/vc4_opt_algebraic.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c
index c114458..ec526fb 100644
--- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c
+++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c
@@ -174,7 +174,10 @@ qir_opt_algebraic(struct vc4_compile *c)
                                  */
                                 replace_with_mov(c, inst, inst->src[1]);
                                 progress = true;
-                        } else if (is_zero(c, defs, inst->src[1])) {
+                                break;
+                        }
+
+                        if (is_zero(c, defs, inst->src[1])) {
                                 /* Replace references to a 0 uniform value
                                  * with the SEL_X_0 equivalent.
                                  */
@@ -183,7 +186,26 @@ qir_opt_algebraic(struct vc4_compile *c)
                                 inst->src[1] = c->undef;
                                 progress = true;
                                 dump_to(c, inst);
+                                break;
                         }
+
+                        if (is_zero(c, defs, inst->src[0])) {
+                                /* Replace references to a 0 uniform value
+                                 * with the SEL_X_0 equivalent, flipping the
+                                 * condition being evaluated since the operand
+                                 * order is flipped.
+                                 */
+                                dump_from(c, inst);
+                                inst->op -= QOP_SEL_X_Y_ZS;
+                                inst->op ^= 1;
+                                inst->op += QOP_SEL_X_0_ZS;
+                                inst->src[0] = inst->src[1];
+                                inst->src[1] = c->undef;
+                                progress = true;
+                                dump_to(c, inst);
+                                break;
+                        }
+
                         break;
 
                 case QOP_FSUB:




More information about the mesa-commit mailing list