[Mesa-dev] [PATCH 12/10] nir/algebraic: add support for declaring that an expression is not used by an if
Timothy Arceri
timothy.arceri at collabora.com
Sun Jan 8 13:05:25 UTC 2017
---
src/compiler/nir/nir_algebraic.py | 4 +++-
src/compiler/nir/nir_search.c | 3 +++
src/compiler/nir/nir_search.h | 3 +++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 04c7423..c0ec019 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -91,6 +91,7 @@ static const ${val.c_type} ${val.name} = {
nir_op_${val.opcode},
{ ${', '.join(src.c_ptr for src in val.sources)} },
${'true' if val.is_many else 'false'},
+ ${'true' if val.is_not_used_by_if else 'false'},
% endif
};""")
@@ -186,7 +187,7 @@ class Variable(Value):
elif self.required_type == 'float':
return "nir_type_float"
-_opcode_re = re.compile(r"(?P<inexact>~)?(?P<many>%)?(?P<opcode>\w+)(?:@(?P<bits>\d+))?")
+_opcode_re = re.compile(r"(?P<inexact>~)?(?P<many>%)?(?P<not_used_by_if>!)?(?P<opcode>\w+)(?:@(?P<bits>\d+))?")
class Expression(Value):
def __init__(self, expr, name_base, varset):
@@ -200,6 +201,7 @@ class Expression(Value):
self.bit_size = int(m.group('bits')) if m.group('bits') else 0
self.inexact = m.group('inexact') is not None
self.is_many = m.group('many') is not None
+ self.is_not_used_by_if = m.group('not_used_by_if') is not None
self.sources = [ Value.create(src, "{0}_{1}".format(name_base, i), varset)
for (i, src) in enumerate(expr[1:]) ]
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 8318c27..e80ec8e 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -264,6 +264,9 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
list_is_singular(&instr->dest.dest.ssa.if_uses))))
return false;
+ if (expr->is_not_used_by_if && !list_empty(&instr->dest.dest.ssa.if_uses))
+ return false;
+
if (instr->op != expr->opcode)
return false;
diff --git a/src/compiler/nir/nir_search.h b/src/compiler/nir/nir_search.h
index 5f1b949..a14f606 100644
--- a/src/compiler/nir/nir_search.h
+++ b/src/compiler/nir/nir_search.h
@@ -106,6 +106,9 @@ typedef struct {
/* Specifies that this expression is used more than once */
bool is_many;
+
+ /* Specifies that this expression is not used by an if */
+ bool is_not_used_by_if;
} nir_search_expression;
NIR_DEFINE_CAST(nir_search_value_as_variable, nir_search_value,
--
2.9.3
More information about the mesa-dev
mailing list