diff options
author | Matt Turner <[email protected]> | 2016-01-21 09:09:29 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2016-02-01 10:43:57 -0800 |
commit | 68f8c5730bef7b93fd235ae2f3c87cc9403b5b4c (patch) | |
tree | 18d11b5509d0874a8ea698e5759faac552eba75d /src/compiler/nir/nir_opt_algebraic.py | |
parent | 8709dc071323eb47be12f0929efe9e0741e9ef30 (diff) |
nir: Add opcodes to extract bytes or words.
The uint versions zero extend while the int versions sign extend.
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_opt_algebraic.py')
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 7745b76f7ce..50d37ea37f1 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -242,6 +242,22 @@ optimizations = [ ('bcsel', ('ult', 31, 'bits'), 'value', ('ubfe', 'value', 'offset', 'bits')), 'options->lower_bitfield_extract'), + + (('extract_i8', a, b), + ('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 24), + 'options->lower_extract_byte'), + + (('extract_u8', a, b), + ('iand', ('ushr', a, ('imul', b, 8)), 0xff), + 'options->lower_extract_byte'), + + (('extract_i16', a, b), + ('ishr', ('ishl', a, ('imul', ('isub', 1, b), 16)), 16), + 'options->lower_extract_word'), + + (('extract_u16', a, b), + ('iand', ('ushr', a, ('imul', b, 16)), 0xffff), + 'options->lower_extract_word'), ] # Add optimizations to handle the case where the result of a ternary is |