nir/uub: improve iand with constant sources

fossil-db (navi21):
Totals from 9 (0.01% of 79653) affected shaders:
Instrs: 11878 -> 11868 (-0.08%)
CodeSize: 61572 -> 61508 (-0.10%)
Latency: 44585 -> 44581 (-0.01%); split: -0.02%, +0.01%
InvThroughput: 9697 -> 9660 (-0.38%)
VALU: 8889 -> 8876 (-0.15%)
SALU: 1339 -> 1342 (+0.22%)

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35514>
This commit is contained in:
Rhys Perry
2025-06-13 11:08:47 +01:00
committed by Marge Bot
parent 8ee5440073
commit ae6ad8977b

View File

@@ -1850,9 +1850,17 @@ get_alu_uub(struct analysis_state *state, struct uub_query q, uint32_t *result,
case nir_op_umax:
*result = src[0] > src[1] ? src[0] : src[1];
break;
case nir_op_iand:
*result = bitmask(util_last_bit64(src[0])) & bitmask(util_last_bit64(src[1]));
case nir_op_iand: {
nir_scalar src0_scalar = nir_scalar_chase_alu_src(q.scalar, 0);
nir_scalar src1_scalar = nir_scalar_chase_alu_src(q.scalar, 1);
if (nir_scalar_is_const(src0_scalar))
*result = bitmask(util_last_bit64(src[1])) & nir_scalar_as_uint(src0_scalar);
else if (nir_scalar_is_const(src1_scalar))
*result = bitmask(util_last_bit64(src[0])) & nir_scalar_as_uint(src1_scalar);
else
*result = bitmask(util_last_bit64(src[0])) & bitmask(util_last_bit64(src[1]));
break;
}
case nir_op_ior:
case nir_op_ixor:
*result = bitmask(util_last_bit64(src[0])) | bitmask(util_last_bit64(src[1]));