glsl/opt_algebraic: Drop add/sub with 0 optimizations.

Looks like minor instruction selection noise in freedreno shader-db:

total instructions in shared programs: 11013100 -> 11013096 (<.01%)
instructions in affected programs: 2714 -> 2710 (-0.15%)
helped: 8
HURT: 6

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>
This commit is contained in:
Emma Anholt
2023-02-22 12:03:34 -08:00
committed by Marge Bot
parent c6908fc8ac
commit 69b178ac90

View File

@@ -322,11 +322,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
#undef HANDLE_PACK_UNPACK_INVERSE
case ir_binop_add:
if (is_vec_zero(op_const[0]))
return ir->operands[1];
if (is_vec_zero(op_const[1]))
return ir->operands[0];
/* Replace (x + (-x)) with constant 0 */
for (int i = 0; i < 2; i++) {
if (op_expr[i]) {
@@ -402,13 +397,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
break;
case ir_binop_sub:
if (is_vec_zero(op_const[0]))
return neg(ir->operands[1]);
if (is_vec_zero(op_const[1]))
return ir->operands[0];
break;
case ir_binop_mul:
if (is_vec_one(op_const[0]))
return ir->operands[1];