nir/constant_expressions: Don't switch on bit size when not needed
For opcodes such as the nir_op_pack_64_2x32 for which all sources and destinations have explicit sizes, the bit_size parameter to the evaluate function is pointless and *should* do nothing. Previously, we were always switching on the bit_size and asserting if it isn't one of the sizes in the list. This generates way more code than needed and is a bit cruel because it doesn't let us have a bit_size of zero on an ALU op which shouldn't need a bit_size. Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
This commit is contained in:
parent
b69b44d222
commit
28e41506a6
|
@ -22,13 +22,18 @@ def type_add_size(type_, size):
|
|||
return type_ + str(size)
|
||||
|
||||
def op_bit_sizes(op):
|
||||
sizes = set([8, 16, 32, 64])
|
||||
sizes = None
|
||||
if not type_has_size(op.output_type):
|
||||
sizes = sizes.intersection(set(type_sizes(op.output_type)))
|
||||
sizes = set(type_sizes(op.output_type))
|
||||
|
||||
for input_type in op.input_types:
|
||||
if not type_has_size(input_type):
|
||||
if sizes is None:
|
||||
sizes = set(type_sizes(input_type))
|
||||
else:
|
||||
sizes = sizes.intersection(set(type_sizes(input_type)))
|
||||
return sorted(list(sizes))
|
||||
|
||||
return sorted(list(sizes)) if sizes is not None else None
|
||||
|
||||
def get_const_field(type_):
|
||||
if type_ == "bool32":
|
||||
|
@ -375,6 +380,7 @@ evaluate_${name}(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
|
|||
{
|
||||
nir_const_value _dst_val = { {0, } };
|
||||
|
||||
% if op_bit_sizes(op) is not None:
|
||||
switch (bit_size) {
|
||||
% for bit_size in op_bit_sizes(op):
|
||||
case ${bit_size}: {
|
||||
|
@ -386,6 +392,9 @@ evaluate_${name}(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
|
|||
default:
|
||||
unreachable("unknown bit width");
|
||||
}
|
||||
% else:
|
||||
${evaluate_op(op, 0)}
|
||||
% endif
|
||||
|
||||
return _dst_val;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue