nir: Add option to lower 64-bit uadd_sat.

C.f. 16be909936.  Intel Xe2 won't
support saturation for 64-bit integer addition, regardless of
signedness.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28283>
This commit is contained in:
Francisco Jerez 2023-01-04 12:51:39 -08:00 committed by Marge Bot
parent 4bb5b25e53
commit 15a10786e3
2 changed files with 4 additions and 2 deletions

View File

@ -3601,6 +3601,7 @@ typedef enum {
nir_lower_iadd_sat64 = (1 << 21),
nir_lower_find_lsb64 = (1 << 22),
nir_lower_conv64 = (1 << 23),
nir_lower_uadd_sat64 = (1 << 24),
} nir_lower_int64_options;
typedef enum {

View File

@ -1995,7 +1995,8 @@ optimizations.extend([
(('imul_32x16', a, b), ('imul', a, ('extract_i16', b, 0)), 'options->lower_mul_32x16'),
(('umul_32x16', a, b), ('imul', a, ('extract_u16', b, 0)), 'options->lower_mul_32x16'),
(('uadd_sat@64', a, b), ('bcsel', ('ult', ('iadd', a, b), a), -1, ('iadd', a, b)), 'options->lower_uadd_sat || (options->lower_int64_options & nir_lower_iadd64) != 0'),
(('uadd_sat@64', a, b), ('bcsel', ('ult', ('iadd', a, b), a), -1, ('iadd', a, b)),
'options->lower_uadd_sat || (options->lower_int64_options & (nir_lower_iadd64 | nir_lower_uadd_sat64)) != 0'),
(('uadd_sat', a, b), ('bcsel', ('ult', ('iadd', a, b), a), -1, ('iadd', a, b)), 'options->lower_uadd_sat'),
(('usub_sat', a, b), ('bcsel', ('ult', a, b), 0, ('isub', a, b)), 'options->lower_usub_sat'),
(('usub_sat@64', a, b), ('bcsel', ('ult', a, b), 0, ('isub', a, b)), '(options->lower_int64_options & nir_lower_usub_sat64) != 0'),
@ -2330,7 +2331,7 @@ optimizations.extend([
for bit_size in [8, 16, 32, 64]:
cond = '!options->lower_uadd_sat'
if bit_size == 64:
cond += ' && !(options->lower_int64_options & nir_lower_iadd64)'
cond += ' && !(options->lower_int64_options & (nir_lower_iadd64 | nir_lower_uadd_sat64))'
add = 'iadd@' + str(bit_size)
optimizations += [