From: Eric Anholt Date: Thu, 27 Jun 2019 21:29:37 +0000 (-0700) Subject: nir: Fix lowering of bitfield_insert to shifts. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8fd8964302af652f7de14923111ca9b15b8d2b48;p=mesa.git nir: Fix lowering of bitfield_insert to shifts. The bfi/bfm behavior change replaced the bfi/bfm usage in lower_bitfield_insert_to_shifts with actual shifts like the name says, but it failed to handle the offset=0, bits==32 case in the new lowering. v2: Use 31 < bits instead of bits == 32, to get the 31 < (iand bits, 31) -> false optimization. Fixes regressions in dEQP-GLES31.*bitfield_insert* on freedreno. Fixes: 165b7f3a4487 ("nir: define behavior of nir_op_bfm and nir_op_u/ibfe according to SM5 spec.") Reviewed-by: Daniel Schürmann --- diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 8b786887052..4fd9a93a22a 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -795,9 +795,11 @@ optimizations.extend([ # Alternative lowering that doesn't rely on bfi. (('bitfield_insert', 'base', 'insert', 'offset', 'bits'), - ('ior', - ('iand', 'base', ('inot', ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))), - ('iand', ('ishl', 'insert', 'offset'), ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))), + ('bcsel', ('ult', 31, 'bits'), + 'insert', + (('ior', + ('iand', 'base', ('inot', ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))), + ('iand', ('ishl', 'insert', 'offset'), ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))))), 'options->lower_bitfield_insert_to_shifts'), # Alternative lowering that uses bitfield_select.