vkd3d-shader/hlsl: Fold some general unary identities.

The following unary identities are applied:

  ||x|| -> |x|
  |-x| -> |x|
  ~(~x) -> x
  f(g(x)) -> g(x), where f(), g() are floor() or ceil() functions.
  -(-x) -> x
  !!x -> x
  !(x == y) -> x != y, !(x < y) -> x >= y, etc (for integers).
This commit is contained in:
Shaun Ren
2025-07-28 21:51:09 -04:00
committed by Henri Verbeet
parent 45e549c1b2
commit 245430002a
Notes: Henri Verbeet 2025-08-21 16:34:36 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1648
5 changed files with 197 additions and 2 deletions

View File

@@ -1541,6 +1541,12 @@ static inline bool hlsl_var_has_buffer_offset_register_reservation(struct hlsl_c
return var->reg_reservation.reg_type == 'c' && var->buffer == ctx->globals_buffer;
}
static inline bool hlsl_is_comparison_op(enum hlsl_ir_expr_op op)
{
return op == HLSL_OP2_EQUAL || op == HLSL_OP2_GEQUAL
|| op == HLSL_OP2_LESS || op == HLSL_OP2_NEQUAL;
}
char *hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt, ...) VKD3D_PRINTF_FUNC(2, 3);
const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op);