[PATCH vkd3d 1/3] vkd3d-shader/hlsl: Handle branches in copy propagation.

Zebediah Figura (she/her) zfigura at codeweavers.com
Fri Dec 17 11:59:31 CST 2021


On 12/17/21 03:22, Giovanni Mascellani wrote:
> Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
> ---
> A new var_def is now initialized to the content of the same var_def
> in earlier stack frames.

I'm not a big fan of this, because now it feels like it's half one thing 
and half the other.

...

> +static void copy_propagation_invalidate_from_block(struct hlsl_ctx *ctx, struct copy_propagation_state *state,
> +        struct hlsl_block *block)
> +{
> +    struct hlsl_ir_node *instr;
> +
> +    LIST_FOR_EACH_ENTRY(instr, &block->instrs, struct hlsl_ir_node, entry)
> +    {
> +        switch (instr->type)
> +        {
> +            case HLSL_IR_STORE:
> +            {
> +                struct hlsl_ir_store *store = hlsl_ir_store(instr);
> +                struct copy_propagation_var_def *var_def;
> +                struct hlsl_deref *lhs = &store->lhs;
> +                struct hlsl_ir_var *var = lhs->var;
> +                unsigned int offset;
> +
> +                if (!(var_def = copy_propagation_get_var_def(state, var)))
> +                    continue;
> +
> +                if (hlsl_offset_from_deref(lhs, &offset))
> +                    copy_propagation_invalidate_variable_partial(state, var_def, offset, store->writemask);
> +                else
> +                    copy_propagation_invalidate_whole_variable(state, var_def);
> +
> +                break;
> +            }
> +
> +            case HLSL_IR_IF:
> +            {
> +                struct hlsl_ir_if *iff = hlsl_ir_if(instr);
> +
> +                copy_propagation_invalidate_from_block(ctx, state, &iff->then_instrs);
> +                copy_propagation_invalidate_from_block(ctx, state, &iff->else_instrs);
> +
> +                break;
> +            }
> +
> +            case HLSL_IR_LOOP:
> +            {
> +                struct hlsl_ir_loop *loop = hlsl_ir_loop(instr);
> +
> +                copy_propagation_invalidate_from_block(ctx, state, &loop->body);
> +
> +                break;
> +            }
> +
> +            default:
> +                break;
> +        }
> +    }
> +}

Something that just occurred to me: could we handle this by instead just 
comparing the var_def structures from the parent and child state, and 
invalidating where they don't match?

Alternatively, probably simpler: could we just recursively invalidate 
parents in copy_propagation_record_store()?



More information about the wine-devel mailing list