[Mesa-dev] [PATCH 04/12] glsl: Refactor a little code in get_intrinsic_opcode

Ian Romanick idr at freedesktop.org
Tue Jul 19 20:13:06 UTC 2016


From: Ian Romanick <ian.d.romanick at intel.com>

   text	   data	    bss	    dec	    hex	filename
7529067	 273096	  28584	7830747	 777cdb	/tmp/i965_dri-64bit-before.so
7529003	 273096	  28584	7830683	 777c9b	/tmp/i965_dri-64bit-after.so

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
---
 src/compiler/glsl/nir_intrinsic_map.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl/nir_intrinsic_map.py b/src/compiler/glsl/nir_intrinsic_map.py
index 4d999c1..f6e9241 100644
--- a/src/compiler/glsl/nir_intrinsic_map.py
+++ b/src/compiler/glsl/nir_intrinsic_map.py
@@ -78,22 +78,28 @@ get_intrinsic_opcode(const char *name, const ir_dereference *return_deref)
    else
       unreachable("Intrinsic name does not begin with '__intrinsic_'");
 
+   nir_intrinsic_op int_op;
+   nir_intrinsic_op uint_op;
+
     % for (name, ops) in intrinsics:
    if (strcmp(name, "${name[12:]}") == 0) {
         % if ops[1] is None:
       return ${ops[0]};
         % else:
-      assert(return_deref);
-      if (return_deref->type == glsl_type::int_type)
-         return ${ops[0]};
-      else if (return_deref->type == glsl_type::uint_type)
-         return ${ops[1]};
-      else
-         unreachable("Invalid type");
+      int_op = ${ops[0]};
+      uint_op = ${ops[1]};
         % endif
    } else
     % endfor
       unreachable("Unknown intrinsic name");
+
+   assert(return_deref);
+   if (return_deref->type == glsl_type::int_type)
+      return int_op;
+   else if (return_deref->type == glsl_type::uint_type)
+      return uint_op;
+   else
+      unreachable("Invalid type");
 }
 }
 """
-- 
2.5.5



More information about the mesa-dev mailing list