summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 987965d23d6..3112623d9ff 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1399,6 +1399,9 @@ optimizations.extend([
('ubfe', 'value', 'offset', 'bits')),
'options->lower_bitfield_extract'),
+ # (src0 & src1) | (~src0 & src2). Constant fold if src2 is 0.
+ (('bitfield_select', a, b, 0), ('iand', a, b)),
+
# Note that these opcodes are defined to only use the five least significant bits of 'offset' and 'bits'
(('ubfe', 'value', 'offset', ('iand', 31, 'bits')), ('ubfe', 'value', 'offset', 'bits')),
(('ubfe', 'value', ('iand', 31, 'offset'), 'bits'), ('ubfe', 'value', 'offset', 'bits')),