On Tue Jan 3 00:41:13 2023 +0000, Francisco Casas wrote:
Good point, if I understood the problem correctly, the new approach covers this.
That's not quite what I'm thinking of either, and it looks more than a little awkward now. The point is (a) we shouldn't have to specially handle loads and swizzles in copy_propagation_transform_swizzle(), and (b) now copy_propagation_compute_constant_replacement() is a weird anti-helper that cares about the type of its argument.
Because this is copy-prop, we are only dealing with swizzled loads, not just any swizzles. So copy_propagation_transform_swizzle() should probably contain that check explicitly. And then my idea is, I think, something like this:
``` static bool copy_propagation_transform_load(struct hlsl_ctx *ctx, struct hlsl_ir_load *load, struct copy_propagation_state *state, unsigned int swizzle) { ... }
static bool copy_propagation_transform_swizzle(...) { ...
if (swizzle->val->type != HLSL_IR_LOAD) return false;
return copy_propagation_transform_load(ctx, hlsl_ir_load(swizzle->val), state, swizzle->swizzle); }
static bool copy_propagation_transform_block(...) { ...
case HLSL_IR_LOAD: progress |= copy_propagation_transform_load(ctx, hlsl_ir_load(instr), state, HLSL_SWIZZLE(X, Y, Z, W)); break; ... } ```