On Mon Jan 29 14:55:32 2024 +0000, Conor McCarthy wrote:
When I tested materialisation of SSA to TEMP a while ago I didn't use MOVC, so I'm wondering if it's needed only because of the structuriser. For example, this:
label l1 ... branch sr1, l2, l3 label l2 mov sr2, v0.x branch l4 label l3 mov sr3, v1.x branch l4 label l4 phi sr5, sr2, l2, sr3, l3
Becomes:
label l1 ... branch r0.x, l2, l3 label l2 mov r1.x, v0.x branch l4 label l3 mov r1.x, v1.x branch l4 label l4
You need MOVC when there is a conditional BRANCH and the PHI nodes is in one of the two branches, not when it is in the merge block. For example: ``` label l1 ... mov sr1, ... mov sr2, ... branch sr2, l2, l3 label l2 phi sr3, sr1, l1, ... ... ```
In that case, the assignment to `r3` (supposedly used to materialize `sr3`) must be moved to block `l1`, but must be executed only if control is going to `l2`. So I convert that to: ``` label l1 ... mov r1, ... mov r2, ... movc r3, r2, r1, r2 branch r2, l2, l3 label l2 ... ```
Of course if `l3` has PHI nodes too, than I'll have to add MOVC instructions for that as well, this time using the "if false" operands. Does that make sense to you?