[PATCH vkd3d 04/17] vkd3d-shader/hlsl: Propagate constant loads in copy propagation.

Giovanni Mascellani gmascellani at codeweavers.com
Fri Dec 3 03:46:41 CST 2021


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---

On 01/12/21 17:14, Matteo Bruni wrote:
> From: Giovanni Mascellani <gmascellani at codeweavers.com>
> 
> Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
> ---
> changelog: Try constant propagation first.

No objections here, but any particular reason?

> @@ -458,6 +500,15 @@ static bool copy_propagation_analyze_load(struct hlsl_ctx *ctx, struct hlsl_ir_l
>       if (!(var_def = copy_propagation_get_var_def(state, var)))
>           return false;
>   
> +    if ((new_node = copy_propagation_compute_constant(ctx, var_def, offset, type->dimx, &load->node.loc)))
> +    {
> +        TRACE("Load from %s[%d-%d] reconstructed as constant value.\n",
> +                var->name, offset, offset + type->dimx);
> +        list_add_before(&node->entry, &new_node->entry);
> +        replace_node(node, new_node);
> +        return true;
> +    }
> +
>       if (!(new_node = copy_propagation_compute_replacement(var_def, offset, type->dimx, &swizzle)))
>       {
>           TRACE("No single source for propagating load from %s[%u-%u].\n", var->name, offset, offset + type->dimx);
> 

I think the code would be more readable it it was like:

---
if (c_p_compute_constant())
{
     ...
     return true;
}

if (c_p_compute_replacement())
{
     ...
     return true;
}

TRACE("failure, no optimization for you today, rotfl lol\n");
return false;
---

But I can live with that too. :-)

Giovanni.



More information about the wine-devel mailing list