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

Author: Emma Anholt <[email protected]>
Date:   Wed Feb 15 17:11:24 2023 -0800

glsl: Drop the (v.x + v.y + v.z + v.w) -> dot(v, 1.0) optimization.

It's not connected up to anything at the moment, and even if I do enable
it for crocus HSW it only shaves 3 instructions off of one particular VS
in an old synthetic benchmark, not affecting anything else in shader-db.
I don't think anyone will care to ever fix or port this to NIR, let's just
retire it.

Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21353>

---

 src/compiler/glsl/opt_algebraic.cpp | 48 -------------------------------------
 1 file changed, 48 deletions(-)

diff --git a/src/compiler/glsl/opt_algebraic.cpp 
b/src/compiler/glsl/opt_algebraic.cpp
index 4f093a2398a..8c3387c57fe 100644
--- a/src/compiler/glsl/opt_algebraic.cpp
+++ b/src/compiler/glsl/opt_algebraic.cpp
@@ -185,46 +185,6 @@ update_type(ir_expression *ir)
       ir->type = ir->operands[1]->type;
 }
 
-/* Recognize (v.x + v.y) + (v.z + v.w) as dot(v, 1.0) */
-static ir_expression *
-try_replace_with_dot(ir_expression *expr0, ir_expression *expr1, void *mem_ctx)
-{
-   if (expr0 && expr0->operation == ir_binop_add &&
-       expr0->type->is_float() &&
-       expr1 && expr1->operation == ir_binop_add &&
-       expr1->type->is_float()) {
-      ir_swizzle *x = expr0->operands[0]->as_swizzle();
-      ir_swizzle *y = expr0->operands[1]->as_swizzle();
-      ir_swizzle *z = expr1->operands[0]->as_swizzle();
-      ir_swizzle *w = expr1->operands[1]->as_swizzle();
-
-      if (!x || x->mask.num_components != 1 ||
-          !y || y->mask.num_components != 1 ||
-          !z || z->mask.num_components != 1 ||
-          !w || w->mask.num_components != 1) {
-         return NULL;
-      }
-
-      bool swiz_seen[4] = {false, false, false, false};
-      swiz_seen[x->mask.x] = true;
-      swiz_seen[y->mask.x] = true;
-      swiz_seen[z->mask.x] = true;
-      swiz_seen[w->mask.x] = true;
-
-      if (!swiz_seen[0] || !swiz_seen[1] ||
-          !swiz_seen[2] || !swiz_seen[3]) {
-         return NULL;
-      }
-
-      if (x->val->equals(y->val) &&
-          x->val->equals(z->val) &&
-          x->val->equals(w->val)) {
-         return dot(x->val, new(mem_ctx) ir_constant(1.0f, 4));
-      }
-   }
-   return NULL;
-}
-
 void
 ir_algebraic_visitor::reassociate_operands(ir_expression *ir1,
                                           int op1,
@@ -497,14 +457,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       if (op_const[1] && !op_const[0])
         reassociate_constant(ir, 1, op_const[1], op_expr[0]);
 
-      /* Recognize (v.x + v.y) + (v.z + v.w) as dot(v, 1.0) */
-      if (options->OptimizeForAOS) {
-         ir_expression *expr = try_replace_with_dot(op_expr[0], op_expr[1],
-                                                    mem_ctx);
-         if (expr)
-            return expr;
-      }
-
       /* Replace (-x + y) * a + x and commutative variations with lrp(x, y, a).
        *
        * (-x + y) * a + x

Reply via email to