On Tue Jan 10 20:03:04 2023 +0000, Zebediah Figura wrote:
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; ... }
Got it.
I am afraid that `copy_propagation_compute_replacement()` will still require to receive an **input swizzle** argument though (which I think adds to the awkwardness). I will see if I can use the current output argument `unsigned int *swizzle` for both the input and output swizzles.