Mesa (master): nir_lower_bit_size: Support lowering ops with differing source/dest sizes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 27 17:32:04 UTC 2020


Module: Mesa
Branch: master
Commit: ea715741b5b31044d00959b61bbc96db913e958e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea715741b5b31044d00959b61bbc96db913e958e

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Mon Jun 22 11:51:09 2020 -0700

nir_lower_bit_size: Support lowering ops with differing source/dest sizes

Specifically the bit-finding routines always return int32. Don't complain
about the dest already being 32 bits when lowering to 32 bits, and
don't bother casting the dest if it's already right.

Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6313>

---

 src/compiler/nir/nir_lower_bit_size.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir_lower_bit_size.c b/src/compiler/nir/nir_lower_bit_size.c
index 71a0f6fcad5..d145cc1ada1 100644
--- a/src/compiler/nir/nir_lower_bit_size.c
+++ b/src/compiler/nir/nir_lower_bit_size.c
@@ -70,9 +70,13 @@ lower_instr(nir_builder *bld, nir_alu_instr *alu, unsigned bit_size)
 
 
    /* Convert result back to the original bit-size */
-   nir_alu_type type = nir_op_infos[op].output_type;
-   nir_ssa_def *dst = nir_convert_to_bit_size(bld, lowered_dst, type, dst_bit_size);
-   nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(dst));
+   if (dst_bit_size != bit_size) {
+      nir_alu_type type = nir_op_infos[op].output_type;
+      nir_ssa_def *dst = nir_convert_to_bit_size(bld, lowered_dst, type, dst_bit_size);
+      nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(dst));
+   } else {
+      nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(lowered_dst));
+   }
 }
 
 static bool
@@ -96,8 +100,6 @@ lower_impl(nir_function_impl *impl,
          if (lower_bit_size == 0)
             continue;
 
-         assert(lower_bit_size != alu->dest.dest.ssa.bit_size);
-
          lower_instr(&b, alu, lower_bit_size);
          progress = true;
       }



More information about the mesa-commit mailing list