From 2491d5a662581518fc01943e5410bab3dc661707 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 4 Feb 2021 13:27:08 -0600 Subject: [PATCH] nir/algebraic: Covert up-cast of down-cast to extract on Intel This starts generating extract for bit sizes other than 32 but our back-end handles that just fine. Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 51ce418dea2..1f12ccbdf1b 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2333,6 +2333,29 @@ late_optimizations = [ (('ushr', a, 0), a), ] +# A few more extract cases we'd rather leave late +for N in [16, 32]: + aN = 'a@{0}'.format(N) + u2uM = 'u2u{0}'.format(M) + i2iM = 'i2i{0}'.format(M) + + for x in ['u', 'i']: + x2xN = '{0}2{0}{1}'.format(x, N) + extract_x8 = 'extract_{0}8'.format(x) + extract_x16 = 'extract_{0}16'.format(x) + + late_optimizations.extend([ + ((x2xN, ('u2u8', aN)), (extract_x8, a, 0), '!options->lower_extract_byte'), + ((x2xN, ('i2i8', aN)), (extract_x8, a, 0), '!options->lower_extract_byte'), + ]) + + if N > 16: + late_optimizations.extend([ + ((x2xN, ('u2u16', aN)), (extract_x16, a, 0), '!options->lower_extract_word'), + ((x2xN, ('i2i16', aN)), (extract_x16, a, 0), '!options->lower_extract_word'), + ]) + + # Integer sizes for s in [8, 16, 32, 64]: late_optimizations.extend([