<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 26, 2015 at 2:47 PM, 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"><div class="HOEnZb"><div class="h5">On Sun, Jan 25, 2015 at 7:51 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
><br>
><br>
> On Sun, Jan 25, 2015 at 8:56 AM, Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
>><br>
>> 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,<br>
>> 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<br>
>> 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>
><br>
><br>
> The name instr_ssa_src_components is kind of deceiving when the source isn't<br>
> what has to be SSA.  It's the destination that's SSA.  I'm not coming up<br>
> with a better name off hand, but we should try and find one.<br>
<br>
</div></div>I'd like to figure out a better one too. Would it be better to put<br>
"ssa" earlier, i.e. nir_ssa_alu_instr_src_components to imply that the<br>
instruction itself has to be SSA? I would say "ssa_dest," but the name<br>
is already awfully long.<br></blockquote><div><br></div><div>Yeah, that sounds fine.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
><br>
> Also, There are a lot of other places that need this than just constant<br>
> folding.  A quick grep for input_sizes would probably reveal the ones that<br>
> are open-coding it.  Other than that, I like the series.<br>
<br>
</span>Sure, sounds like a good idea. I wanted to get this out soon since<br>
it's a pretty bad bug and I was a little embarrassed not catching it<br>
while writing it or during review, but I'll go ahead and do that.<br></blockquote><div><br></div><div>That's fair.  It can be a second patch.<br><br>With the new name, both are<br>Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> --Jason<br>
><br>
>><br>
>> +{<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>
>> --<br>
>> 2.1.0<br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>