mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
pan/mdg: Optimize b32csel(inot) in NIR
This is a generic algebraic optimization. Use the generic algebraic optimizer. The only reason we can't rely on nir_opt_algebraic to do this is because we generate inot's late in order to optimize some comparisons. But we already have a pass to clean that up (midgard_nir_clean_inot), it just needs to be extended to handle more cases. shader-db is noise: total bundles in shared programs: 646941 -> 646942 (<.01%) bundles in affected programs: 100 -> 101 (1.00%) helped: 0 HURT: 1 total quadwords in shared programs: 1134727 -> 1134726 (<.01%) quadwords in affected programs: 318 -> 317 (-0.31%) helped: 2 HURT: 1 total registers in shared programs: 90619 -> 90618 (<.01%) registers in affected programs: 12 -> 11 (-8.33%) helped: 1 HURT: 0 Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Italo Nicola <italonicola@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23769>
This commit is contained in:
parent
d1f6bcd1d0
commit
311bfd0623
2 changed files with 2 additions and 10 deletions
|
|
@ -588,9 +588,6 @@ nir_accepts_inot(nir_op op, unsigned src)
|
|||
case nir_op_iand: /* TODO: b2f16 */
|
||||
case nir_op_ixor:
|
||||
return true;
|
||||
case nir_op_b32csel:
|
||||
/* Only the condition */
|
||||
return (src == 0);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1042,12 +1039,6 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
|
|||
|
||||
mir_copy_src(&ins, instr, i, to, &ins.src_abs[to], &ins.src_neg[to],
|
||||
&ins.src_invert[to], roundptr, is_int, broadcast_swizzle);
|
||||
|
||||
/* (!c) ? a : b = c ? b : a */
|
||||
if (instr->op == nir_op_b32csel && ins.src_invert[2]) {
|
||||
ins.src_invert[2] = false;
|
||||
flip_src12 ^= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ constant_switch = [
|
|||
|
||||
# ..since the above switching happens after algebraic stuff is done
|
||||
cancel_inot = [
|
||||
(('inot', ('inot', a)), a)
|
||||
(('inot', ('inot', a)), a),
|
||||
(('b32csel', ('inot', a), b, c), ('b32csel', a, c, b)),
|
||||
]
|
||||
|
||||
def main():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue