glsl/opt_algebraic: Drop pow optimizations.
authorEmma Anholt <emma@anholt.net>
Wed, 22 Feb 2023 19:54:15 +0000 (11:54 -0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 28 Feb 2023 03:36:08 +0000 (03:36 +0000)
These should all be covered by NIR.  Minor shader-db changes on freedreno,
which appear to be scheduling noise.

total instructions in shared programs: 11013132 -> 11013112 (<.01%)
instructions in affected programs: 3408 -> 3388 (-0.59%)

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21475>

src/compiler/glsl/opt_algebraic.cpp

index a80e68a..8949fa2 100644 (file)
@@ -113,18 +113,6 @@ is_vec_one(ir_constant *ir)
 }
 
 static inline bool
-is_vec_two(ir_constant *ir)
-{
-   return (ir == NULL) ? false : ir->is_value(2.0, 2);
-}
-
-static inline bool
-is_vec_four(ir_constant *ir)
-{
-   return (ir == NULL) ? false : ir->is_value(4.0, 4);
-}
-
-static inline bool
 is_vec_negative_one(ir_constant *ir)
 {
    return (ir == NULL) ? false : ir->is_negative_one();
@@ -635,43 +623,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       }
       break;
 
-   case ir_binop_pow:
-      /* 1^x == 1 */
-      if (is_vec_one(op_const[0]))
-         return op_const[0];
-
-      /* x^1 == x */
-      if (is_vec_one(op_const[1]))
-         return ir->operands[0];
-
-      /* pow(2,x) == exp2(x) */
-      if (is_vec_two(op_const[0]))
-         return expr(ir_unop_exp2, ir->operands[1]);
-
-      if (is_vec_two(op_const[1])) {
-         ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
-                                              ir_var_temporary);
-         base_ir->insert_before(x);
-         base_ir->insert_before(assign(x, ir->operands[0]));
-         return mul(x, x);
-      }
-
-      if (is_vec_four(op_const[1])) {
-         ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
-                                              ir_var_temporary);
-         base_ir->insert_before(x);
-         base_ir->insert_before(assign(x, ir->operands[0]));
-
-         ir_variable *squared = new(ir) ir_variable(ir->operands[1]->type,
-                                                    "squared",
-                                                    ir_var_temporary);
-         base_ir->insert_before(squared);
-         base_ir->insert_before(assign(squared, mul(x, x)));
-         return mul(squared, squared);
-      }
-
-      break;
-
    case ir_binop_min:
    case ir_binop_max:
       if (!ir->type->is_float())