<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 25, 2015 at 8:56 AM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Unlike with non-SSA ALU instructions, where if they're per-component<br>
you have to look at the writemask to know which source channels are<br>
being used, SSA ALU instructions always have all the possible channels<br>
enabled so we can just look at the number of components in the SSA<br>
definition for per-component instructions to say how many source<br>
components are being used.<br>
<br>
Signed-off-by: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
---<br>
 src/glsl/nir/nir.h | 15 +++++++++++++++<br>
 1 file changed, 15 insertions(+)<br>
<br>
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h<br>
index 0ef83a1..efcaa9d 100644<br>
--- a/src/glsl/nir/nir.h<br>
+++ b/src/glsl/nir/nir.h<br>
@@ -652,6 +652,21 @@ nir_alu_instr_channel_used(nir_alu_instr *instr, unsigned src, unsigned channel)<br>
    return (instr->dest.write_mask >> channel) & 1;<br>
 }<br>
<br>
+/*<br>
+ * For instructions whose destinations are SSA, get the number of channels<br>
+ * used for a source<br>
+ */<br>
+static inline unsigned<br>
+nir_alu_instr_ssa_src_components(nir_alu_instr *instr, unsigned src)<br></blockquote><div><br></div><div>The name instr_ssa_src_components is kind of deceiving when the source isn't what has to be SSA.  It's the destination that's SSA.  I'm not coming up with a better name off hand, but we should try and find one.<br><br></div><div>Also, There are a lot of other places that need this than just constant folding.  A quick grep for input_sizes would probably reveal the ones that are open-coding it.  Other than that, I like the series.<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+   assert(instr->dest.dest.is_ssa);<br>
+<br>
+   if (nir_op_infos[instr->op].input_sizes[src] > 0)<br>
+      return nir_op_infos[instr->op].input_sizes[src];<br>
+<br>
+   return instr->dest.dest.ssa.num_components;<br>
+}<br>
+<br>
 typedef enum {<br>
    nir_deref_type_var,<br>
    nir_deref_type_array,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.0<br>
<br>
</font></span></blockquote></div><br></div></div>