Skip to content

Commit

Permalink
glsl/opt_algebraic: Drop the ftrunc pattern recognizer.
Browse files Browse the repository at this point in the history
Now that it's in NIR, there's no change to r300 or freedreno shader-db
when we do.

Acked-by: Timothy Arceri <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21475>
  • Loading branch information
anholt authored and Marge Bot committed Feb 28, 2023
1 parent 6d52e6f commit 579aca8
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions src/compiler/glsl/opt_algebraic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,42 +347,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
reassociate_constant(ir, 0, op_const[0], op_expr[1]);
if (op_const[1] && !op_const[0])
reassociate_constant(ir, 1, op_const[1], op_expr[0]);

/* Optimizes
*
* (mul (floor (add (abs x) 0.5) (sign x)))
*
* into
*
* (trunc (add x (mul (sign x) 0.5)))
*/
for (int i = 0; i < 2; i++) {
ir_expression *sign_expr = ir->operands[i]->as_expression();
ir_expression *floor_expr = ir->operands[1 - i]->as_expression();

if (!sign_expr || sign_expr->operation != ir_unop_sign ||
!floor_expr || floor_expr->operation != ir_unop_floor)
continue;

ir_expression *add_expr = floor_expr->operands[0]->as_expression();
if (!add_expr || add_expr->operation != ir_binop_add)
continue;

for (int j = 0; j < 2; j++) {
ir_expression *abs_expr = add_expr->operands[j]->as_expression();
if (!abs_expr || abs_expr->operation != ir_unop_abs)
continue;

ir_constant *point_five = add_expr->operands[1 - j]->as_constant();
if (!point_five || !point_five->is_value(0.5, 0))
continue;

if (abs_expr->operands[0]->equals(sign_expr->operands[0])) {
return trunc(add(abs_expr->operands[0],
mul(sign_expr, point_five)));
}
}
}
break;

case ir_binop_min:
Expand Down

0 comments on commit 579aca8

Please sign in to comment.