Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl.y:
- if (!(x = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
return false;
- if (!(y = intrinsic_float_convert_arg(ctx, params, params->args[1], loc)))
return false;
- if (!(div = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_DIV, x, y, loc)))
return false;
- if (!(zero = hlsl_new_constant(ctx, div->data_type, loc)))
return false;
- list_add_tail(params->instrs, &zero->node.entry);
- count = hlsl_type_element_count(div->data_type);
- for (i = 0; i < count; ++i)
zero->value.u[i].f = 0.0f;
I think we can take for granted that it's part of the contract of `hlsl_new_constant()` that the returned constant is zero for all numerical data types. Not that this code is wrong, but it can be dropped.