From 15a10786e317710970102e0f22cf785a0876920e Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Wed, 4 Jan 2023 12:51:39 -0800 Subject: [PATCH] nir: Add option to lower 64-bit uadd_sat. C.f. 16be90993683211b4750b531961a25ff1348e475. Intel Xe2 won't support saturation for 64-bit integer addition, regardless of signedness. Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_opt_algebraic.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 526600eb40b..9a74114f0a3 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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 { diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 5c3d8abd3c8..c2ceb5d8007 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -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 += [