glsl: drop sub to add neg lowering in GLSL IR
NIR opt algebraic does this for us so no need to have it implemented here also. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19112>
This commit is contained in:

committed by
Marge Bot

parent
a31c547206
commit
9f14c5dae2
@@ -2381,8 +2381,6 @@ do_common_optimization(exec_list *ir, bool linked,
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
OPT(lower_instructions, ir, SUB_TO_ADD_NEG);
|
||||
|
||||
if (linked) {
|
||||
OPT(do_function_inlining, ir);
|
||||
OPT(do_dead_functions, ir);
|
||||
|
@@ -34,7 +34,6 @@ struct gl_linked_shader;
|
||||
struct gl_shader_program;
|
||||
|
||||
/* Operations for lower_instructions() */
|
||||
#define SUB_TO_ADD_NEG 0x01
|
||||
#define LDEXP_TO_ARITH 0x80
|
||||
#define CARRY_TO_ARITH 0x100
|
||||
#define BORROW_TO_ARITH 0x200
|
||||
|
@@ -30,22 +30,11 @@
|
||||
* rather than in each driver backend.
|
||||
*
|
||||
* Currently supported transformations:
|
||||
* - SUB_TO_ADD_NEG
|
||||
* - LDEXP_TO_ARITH
|
||||
* - CARRY_TO_ARITH
|
||||
* - BORROW_TO_ARITH
|
||||
* - DOPS_TO_DFRAC
|
||||
*
|
||||
* SUB_TO_ADD_NEG:
|
||||
* ---------------
|
||||
* Breaks an ir_binop_sub expression down to add(op0, neg(op1))
|
||||
*
|
||||
* This simplifies expression reassociation, and for many backends
|
||||
* there is no subtract operation separate from adding the negation.
|
||||
* For backends with native subtract operations, they will probably
|
||||
* want to recognize add(op0, neg(op1)) or the other way around to
|
||||
* produce a subtract anyway.
|
||||
*
|
||||
* LDEXP_TO_ARITH:
|
||||
* -------------
|
||||
* Converts ir_binop_ldexp to arithmetic and bit operations for float sources.
|
||||
@@ -93,7 +82,6 @@ public:
|
||||
private:
|
||||
unsigned lower; /** Bitfield of which operations to lower */
|
||||
|
||||
void sub_to_add_neg(ir_expression *);
|
||||
void ldexp_to_arith(ir_expression *);
|
||||
void dldexp_to_arith(ir_expression *);
|
||||
void dfrexp_sig_to_arith(ir_expression *);
|
||||
@@ -140,16 +128,6 @@ lower_instructions(exec_list *instructions, unsigned what_to_lower)
|
||||
return v.progress;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::sub_to_add_neg(ir_expression *ir)
|
||||
{
|
||||
ir->operation = ir_binop_add;
|
||||
ir->init_num_operands();
|
||||
ir->operands[1] = new(ir) ir_expression(ir_unop_neg, ir->operands[1]->type,
|
||||
ir->operands[1], NULL);
|
||||
this->progress = true;
|
||||
}
|
||||
|
||||
void
|
||||
lower_instructions_visitor::ldexp_to_arith(ir_expression *ir)
|
||||
{
|
||||
@@ -1452,10 +1430,6 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
|
||||
if (ir->operands[0]->type->is_double())
|
||||
double_lrp(ir);
|
||||
break;
|
||||
case ir_binop_sub:
|
||||
if (lowering(SUB_TO_ADD_NEG))
|
||||
sub_to_add_neg(ir);
|
||||
break;
|
||||
|
||||
case ir_binop_ldexp:
|
||||
if (lowering(LDEXP_TO_ARITH) && ir->type->is_float())
|
||||
|
@@ -1318,7 +1318,7 @@ TESTS = [
|
||||
color *= borrow;
|
||||
}
|
||||
""",
|
||||
r'expression uint \+ \(var_ref x\) \(expression uint neg'),
|
||||
r'expression uint \- \(var_ref x\) \(var_ref y'),
|
||||
Test("imulExtended",
|
||||
"""
|
||||
#version 310 es
|
||||
|
Reference in New Issue
Block a user