mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 11:28:05 +02:00
nir/opt_generate_bfi: avoid trivial instructions
With the pass order shuffling, code like `(x & 0xf) + (x & 0xfffffff0)` gets optimized to bitfield_select(0xF, x, x). But it would be much better to optimize simply to x. nir_opt_algebraic would do that for us but we run this pass too late for algebraic to save us from ourselves, so be smarter. Observed on dEQP-GLES31.functional.compute.basic.image_atomic_op_local_size_8 with Jay, this saves an instruction there. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40956>
This commit is contained in:
parent
f137207108
commit
4b81cb6206
1 changed files with 8 additions and 0 deletions
|
|
@ -146,6 +146,14 @@ nir_opt_generate_bfi_instr(nir_builder *b,
|
|||
|
||||
b->cursor = nir_before_instr(&alu->instr);
|
||||
|
||||
/* Optimize with the rule bitfield_select(a, b, b) = b. We do this ourselves
|
||||
* since we run late after nir_opt_algebraic.
|
||||
*/
|
||||
if (alu->def.num_components == 1 && nir_scalar_equal(insert[0], base[0])) {
|
||||
nir_def_replace(&alu->def, nir_mov_scalar(b, insert[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
nir_def *mask_vec = nir_build_imm(b, alu->def.num_components, alu->def.bit_size, mask_cvals);
|
||||
nir_def *insert_vec = nir_vec_scalars(b, insert, alu->def.num_components);
|
||||
nir_def *base_vec = nir_vec_scalars(b, base, alu->def.num_components);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue