[Mesa-dev] [PATCH 12/10] nir/algebraic: add support for declaring that an expression is not used by an if

Jason Ekstrand jason at jlekstrand.net
Sun Jan 8 16:17:22 UTC 2017


The number of little single-character prefixes is starting to get
out-of-hand.  Could we instead work the condition function pointer stuff a
bit and use that for "is used in if" and "has multiple uses"?  I've got
some more detailed ideas about that but I need to be in front of my laptop
to really discuss them.

On Jan 8, 2017 5:06 AM, "Timothy Arceri" <timothy.arceri at collabora.com>
wrote:

---
 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

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170108/a3c212a3/attachment.html>


More information about the mesa-dev mailing list