mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
nir/lower_alu: drop unnecessary iand on uadd_carry result
uadd_carry returns 1 or 0, so ANDing with 1 is unnecessary. Probably this was implemented thinking that it was returning a boolean value. shader-db results for V3D: total instructions in shared programs: 12463571 -> 12462964 (<.01%) instructions in affected programs: 28994 -> 28387 (-2.09%) helped: 110 HURT: 1 total uniforms in shared programs: 3704591 -> 3704588 (<.01%) uniforms in affected programs: 247 -> 244 (-1.21%) helped: 3 HURT: 0 total max-temps in shared programs: 2148138 -> 2148117 (<.01%) max-temps in affected programs: 729 -> 708 (-2.88%) helped: 23 HURT: 2 total sfu-stalls in shared programs: 21230 -> 21232 (<.01%) sfu-stalls in affected programs: 0 -> 2 helped: 0 HURT: 2 Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17903>
This commit is contained in:
parent
8ecea47f06
commit
9d6770d20a
1 changed files with 4 additions and 8 deletions
|
|
@ -147,7 +147,6 @@ lower_alu_instr(nir_alu_instr *instr, nir_builder *b)
|
|||
nir_ssa_def *dest_shifted = nir_ishr(b, dest_32, nir_imm_int(b, src0->bit_size));
|
||||
lowered = nir_build_alu(b, downscast_op, dest_shifted, NULL, NULL, NULL);
|
||||
} else {
|
||||
nir_ssa_def *c1 = nir_imm_intN_t(b, 1, src0->bit_size);
|
||||
nir_ssa_def *cshift = nir_imm_int(b, src0->bit_size / 2);
|
||||
nir_ssa_def *cmask = nir_imm_intN_t(b, (1ull << (src0->bit_size / 2)) - 1, src0->bit_size);
|
||||
nir_ssa_def *different_signs = NULL;
|
||||
|
|
@ -180,12 +179,12 @@ lower_alu_instr(nir_alu_instr *instr, nir_builder *b)
|
|||
nir_ssa_def *tmp;
|
||||
|
||||
tmp = nir_ishl(b, m1, cshift);
|
||||
hi = nir_iadd(b, hi, nir_iand(b, nir_uadd_carry(b, lo, tmp), c1));
|
||||
hi = nir_iadd(b, hi, nir_uadd_carry(b, lo, tmp));
|
||||
lo = nir_iadd(b, lo, tmp);
|
||||
hi = nir_iadd(b, hi, nir_ushr(b, m1, cshift));
|
||||
|
||||
tmp = nir_ishl(b, m2, cshift);
|
||||
hi = nir_iadd(b, hi, nir_iand(b, nir_uadd_carry(b, lo, tmp), c1));
|
||||
hi = nir_iadd(b, hi, nir_uadd_carry(b, lo, tmp));
|
||||
lo = nir_iadd(b, lo, tmp);
|
||||
hi = nir_iadd(b, hi, nir_ushr(b, m2, cshift));
|
||||
|
||||
|
|
@ -195,14 +194,11 @@ lower_alu_instr(nir_alu_instr *instr, nir_builder *b)
|
|||
* high 32-bits. Consider -3 * 2. The high 32-bits is 0, but the
|
||||
* desired result is -1, not -0! Recall -x == ~x + 1.
|
||||
*/
|
||||
nir_ssa_def *c1 = nir_imm_intN_t(b, 1, src0->bit_size);
|
||||
hi = nir_bcsel(b, different_signs,
|
||||
nir_iadd(b,
|
||||
nir_inot(b, hi),
|
||||
nir_iand(b,
|
||||
nir_uadd_carry(b,
|
||||
nir_inot(b, lo),
|
||||
c1),
|
||||
nir_imm_intN_t(b, 1, src0->bit_size))),
|
||||
nir_uadd_carry(b, nir_inot(b, lo), c1)),
|
||||
hi);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue