summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py3
-rw-r--r--src/compiler/nir/nir_search_helpers.h6
2 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 4d01f110f80..a2079140900 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -298,6 +298,7 @@ optimizations = [
(('~bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
(('~bcsel', ('fge', a, b), b, a), ('fmin', a, b)),
(('~bcsel', ('fge', b, a), b, a), ('fmax', a, b)),
+ (('bcsel', ('i2b', a), b, c), ('bcsel', ('ine', a, 0), b, c)),
(('bcsel', ('inot', a), b, c), ('bcsel', a, c, b)),
(('bcsel', a, ('bcsel', a, b, c), d), ('bcsel', a, b, d)),
(('bcsel', a, b, ('bcsel', a, c, d)), ('bcsel', a, b, d)),
@@ -519,6 +520,8 @@ optimizations = [
(('fsqrt', a), ('frcp', ('frsq', a)), 'options->lower_fsqrt'),
(('~frcp', ('frsq', a)), ('fsqrt', a), '!options->lower_fsqrt'),
# Boolean simplifications
+ (('i2b32(is_used_by_if)', a), ('ine32', a, 0)),
+ (('i2b1(is_used_by_if)', a), ('ine', a, 0)),
(('ieq', 'a@bool', True), a),
(('ine(is_not_used_by_if)', 'a@bool', True), ('inot', a)),
(('ine', 'a@bool', False), a),
diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h
index 89f1cba5c52..456de81e175 100644
--- a/src/compiler/nir/nir_search_helpers.h
+++ b/src/compiler/nir/nir_search_helpers.h
@@ -155,6 +155,12 @@ is_used_once(nir_alu_instr *instr)
}
static inline bool
+is_used_by_if(nir_alu_instr *instr)
+{
+ return !list_empty(&instr->dest.dest.ssa.if_uses);
+}
+
+static inline bool
is_not_used_by_if(nir_alu_instr *instr)
{
return list_empty(&instr->dest.dest.ssa.if_uses);