From e905e0938a7f027e3ccda99ac0dd3cb7c4d46901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Fri, 23 Apr 2021 08:48:46 +0200 Subject: [PATCH] nir: Support upper bound of unsigned bit size conversions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These allow us to generate slightly better code in some cases, eg. multiplications in ACO. Signed-off-by: Timur Kristóf Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_range_analysis.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index 75632783c10..1d7eb99283e 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -1457,6 +1457,15 @@ nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht, case nir_op_f2u32: case nir_op_fmul: break; + case nir_op_u2u1: + case nir_op_u2u8: + case nir_op_u2u16: + case nir_op_u2u32: + if (nir_ssa_scalar_chase_alu_src(scalar, 0).def->bit_size > 32) { + /* If src is >32 bits, return max */ + return max; + } + break; default: return max; } @@ -1570,6 +1579,12 @@ nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht, memcpy(&res, &max_f, 4); } break; + case nir_op_u2u1: + case nir_op_u2u8: + case nir_op_u2u16: + case nir_op_u2u32: + res = MIN2(src0, max); + break; default: res = max; break;