Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_codegen.c:
struct hlsl_constant_value zero_value;memset(operands, 0, sizeof(operands));operands[0] = arg2_cast;if (!(neg = hlsl_new_expr(ctx, HLSL_OP1_NEG, operands, float_type, &instr->loc)))return false;hlsl_block_add_instr(block, neg);memset(operands, 0, sizeof(operands));operands[0] = arg1_cast;operands[1] = neg;if (!(sub = hlsl_new_expr(ctx, HLSL_OP2_ADD, operands, float_type, &instr->loc)))return false;hlsl_block_add_instr(block, sub);/* Use MUL as a precarious ABS. */
Why aren't you using ABS itself?