[Mesa-dev] [PATCH 10/13] nir: verify destination bit size when checking algebraic optimizations
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Mon Apr 25 06:19:42 UTC 2016
On 24/04/16 06:49, Jason Ekstrand wrote:
> On Apr 12, 2016 1:06 AM, "Samuel Iglesias Gonsálvez" <siglesias at igalia.com>
> wrote:
>>
>> Some instructions (like flrp in i965) cannot be lowered depending on the
>> bit size because it doesn't support all bit sizes.
>>
>> If the bit size field is defined in nir_opt_algebraic.py, take it into
>> account.
>
> I'm sorry I keep punting on this patch. I've never really like tacking yet
> another argument on to the end of the expression but for a long time i
> couldn't cone up with anything better. How about this: Add a bit_size
> field to nir_search_value and allow you to write 'flrp at 64' to indicate a
> 64-bit destination on an ALU op, 'x at 64' to indicate a 64-bit "variable",
> and '1.0 at 64' to indicate a 64-bit constant. Then it could be used both to
> check for a particular bit-size in the search expression and to allow you
> to specify a bit-size when constructing a value in case it's ambiguous.
>
> If you're amenable to the idea, I'll hack on it a bit on Monday. I've been
> meaning to add a bit-size validator to nir_algebraic.py for some time now
> anyway.
>
Yeah, I like your proposal. Go ahead :)
Thanks for taking care of this.
Sam
> --Jason
>
>> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
>> ---
>> src/compiler/nir/nir_algebraic.py | 11 ++++++++++-
>> 1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/compiler/nir/nir_algebraic.py
> b/src/compiler/nir/nir_algebraic.py
>> index 53a7907..f3630e0 100644
>> --- a/src/compiler/nir/nir_algebraic.py
>> +++ b/src/compiler/nir/nir_algebraic.py
>> @@ -180,6 +180,11 @@ class SearchAndReplace(object):
>> else:
>> self.condition = 'true'
>>
>> + if len(transform) > 3:
>> + self.bit_size = transform[3]
>> + else:
>> + self.bit_size = 0
>> +
>> if self.condition not in condition_list:
>> condition_list.append(self.condition)
>> self.condition_index = condition_list.index(self.condition)
>> @@ -208,6 +213,7 @@ struct transform {
>> const nir_search_expression *search;
>> const nir_search_value *replace;
>> unsigned condition_offset;
>> + unsigned bit_size;
>> };
>>
>> struct opt_state {
>> @@ -226,7 +232,7 @@ struct opt_state {
>>
>> static const struct transform ${pass_name}_${opcode}_xforms[] = {
>> % for xform in xform_list:
>> - { &${xform.search.name}, ${xform.replace.c_ptr},
> ${xform.condition_index} },
>> + { &${xform.search.name}, ${xform.replace.c_ptr},
> ${xform.condition_index}, ${xform.bit_size}},
>> % endfor
>> };
>> % endfor
>> @@ -249,6 +255,9 @@ ${pass_name}_block(nir_block *block, void *void_state)
>> case nir_op_${opcode}:
>> for (unsigned i = 0; i <
> ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
>> const struct transform *xform =
> &${pass_name}_${opcode}_xforms[i];
>> + if (xform->bit_size != 0 &&
>> + alu->dest.dest.ssa.bit_size != xform->bit_size)
>> + continue;
>> if (state->condition_flags[xform->condition_offset] &&
>> nir_replace_instr(alu, xform->search, xform->replace,
>> state->mem_ctx)) {
>> --
>> 2.5.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list