mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Implement normalization of binary expressions.
We normalize binary expressions by attempting to group constants together, in order to facilitate further simplification of the expressions. For any binary operator OP, non-constants x, y, and constants a, b, we apply the following rewrite rules: a OP x -> x OP a, if OP is commutative. (x OP a) OP b -> x OP (a OP b), if OP is associative. (x OP a) OP y -> (x OP y) OP a, if OP is associative and commutative. x OP (y OP a) -> (x OP y) OP a, if OP is associative. Note that we consider floating point operations to be non-associative.
This commit is contained in:
Notes:
Henri Verbeet
2024-12-11 15:37:25 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1307
@@ -6569,6 +6569,7 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
||||
{
|
||||
progress = hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, body, NULL);
|
||||
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_identities, body, NULL);
|
||||
progress |= hlsl_transform_ir(ctx, hlsl_normalize_binary_exprs, body, NULL);
|
||||
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_swizzles, body, NULL);
|
||||
progress |= hlsl_copy_propagation_execute(ctx, body);
|
||||
progress |= hlsl_transform_ir(ctx, fold_swizzle_chains, body, NULL);
|
||||
|
Reference in New Issue
Block a user