Commit 6353d511 authored by Rhys Perry's avatar Rhys Perry
Browse files

nir: look through bcsel in is_only_used_as_float and is_created_as_float



fossil-db (GFX10.3):
Totals from 1 (0.00% of 146267) affected shaders:
CodeSize: 1740 -> 1736 (-0.23%)
Instrs: 313 -> 312 (-0.32%)

fossil-db (GFX10.3, dxvk float controls):
Totals from 143 (0.10% of 146267) affected shaders:
CodeSize: 1492300 -> 1491152 (-0.08%)
Instrs: 300391 -> 300101 (-0.10%)
Signed-off-by: Rhys Perry's avatarRhys Perry <pendingchaos02@gmail.com>
parent 65b0f4b1
Pipeline #275650 waiting for manual action with stages
in 36 seconds
......@@ -1238,6 +1238,20 @@ nir_op_is_vec(nir_op op)
}
}
static inline bool
nir_op_is_bcsel(nir_op op)
{
switch (op) {
case nir_op_bcsel:
case nir_op_b8csel:
case nir_op_b16csel:
case nir_op_b32csel:
return true;
default:
return false;
}
}
static inline bool
nir_is_float_control_signed_zero_inf_nan_preserve(unsigned execution_mode, unsigned bit_size)
{
......
......@@ -280,6 +280,11 @@ is_created_as_float(struct hash_table *ht, nir_shader *shader,
if (src_alu == NULL)
return true;
if (nir_op_is_bcsel(src_alu->op)) {
return is_created_as_float(ht, shader, src_alu, 1, 0, NULL) &&
is_created_as_float(ht, shader, src_alu, 2, 0, NULL);
}
nir_alu_type output_type = nir_op_infos[src_alu->op].output_type;
return nir_alu_type_get_base_type(output_type) == nir_type_float;
}
......@@ -341,16 +346,22 @@ static inline bool
is_only_used_as_float(nir_alu_instr *instr)
{
nir_foreach_use(src, &instr->dest.dest.ssa) {
const nir_instr *const user_instr = src->parent_instr;
nir_instr *user_instr = src->parent_instr;
if (user_instr->type != nir_instr_type_alu)
return false;
const nir_alu_instr *const user_alu = nir_instr_as_alu(user_instr);
nir_alu_instr *user_alu = nir_instr_as_alu(user_instr);
assert(instr != user_alu);
unsigned index = (nir_alu_src*)container_of(src, nir_alu_src, src) - user_alu->src;
if (nir_op_infos[user_alu->op].input_types[index] != nir_type_float)
return false;
if (index != 0 && nir_op_is_bcsel(user_alu->op)) {
if (!is_only_used_as_float(user_alu))
return false;
} else {
if (nir_op_infos[user_alu->op].input_types[index] != nir_type_float)
return false;
}
}
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment