Module: Mesa
Branch: staging/20.2
Commit: cac1e639319bbbf7d94b36c5a4f09fb9742d8ad8
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cac1e639319bbbf7d94b36c5a4f09fb9742d8ad8

Author: Rhys Perry <[email protected]>
Date:   Tue Nov  3 13:17:22 2020 +0000

nir: add nir_alu_src_is_trivial_ssa()

Signed-off-by: Rhys Perry <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7426>
(cherry picked from commit 1df2fc9f9c8d720d05bf1da7b2baf659bfae98ed)

---

 .pick_status.json      |  2 +-
 src/compiler/nir/nir.c | 14 ++++++++++++++
 src/compiler/nir/nir.h |  2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 57773eab751..8891567290b 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4486,7 +4486,7 @@
         "description": "nir: add nir_alu_src_is_trivial_ssa()",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index e17b11cdd4a..ba1e201c1da 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -271,6 +271,20 @@ nir_alu_dest_copy(nir_alu_dest *dest, const nir_alu_dest 
*src,
    dest->saturate = src->saturate;
 }
 
+bool
+nir_alu_src_is_trivial_ssa(const nir_alu_instr *alu, unsigned srcn)
+{
+   static uint8_t trivial_swizzle[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15 };
+   STATIC_ASSERT(ARRAY_SIZE(trivial_swizzle) == NIR_MAX_VEC_COMPONENTS);
+
+   const nir_alu_src *src = &alu->src[srcn];
+   unsigned num_components = nir_ssa_alu_instr_src_components(alu, srcn);
+
+   return src->src.is_ssa && (src->src.ssa->num_components == num_components) 
&&
+          !src->abs && !src->negate &&
+          (memcmp(src->swizzle, trivial_swizzle, num_components) == 0);
+}
+
 
 static void
 cf_init(nir_cf_node *node, nir_cf_node_type type)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index e3328962ea2..758899efcca 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1406,6 +1406,8 @@ bool nir_alu_srcs_negative_equal(const nir_alu_instr 
*alu1,
                                  const nir_alu_instr *alu2,
                                  unsigned src1, unsigned src2);
 
+bool nir_alu_src_is_trivial_ssa(const nir_alu_instr *alu, unsigned srcn);
+
 typedef enum {
    nir_deref_type_var,
    nir_deref_type_array,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to