Re: [PATCH v2 0/1] MR203: vkd3d-shader/hlsl: Fold constant integral abs().
Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_constant_ops.c:
+ + for (k = 0; k < 4; ++k) + { + switch (type) + { + case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: + dst->value.u[k].f = fabsf(src->value.u[k].f); + break; + + case HLSL_TYPE_DOUBLE: + dst->value.u[k].d = fabs(src->value.u[k].d); + break; + + case HLSL_TYPE_INT: + dst->value.u[k].i = abs(src->value.u[k].i); This is undefined behavior on `INT_MIN`.
Actually, this case is somewhat interesting, because `lower_int_abs()` runs before constant expression folding, and should get rid of all `int` absolute values. So in principle we could stick `vkd3d_unreachable()` here. However `lower_int_abs()` does not run when doing constant folding from `evaluate_static_expression_as_uint()`, so this is still reachable. I'm not sure of what the others think, but I think I would be in favor to stipulating that this is unreachable and add other passes to `evaluate_static_expression_as_uint()`. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/203#note_32259
participants (1)
-
Giovanni Mascellani (@giomasce)