On Mon Jan 29 15:56:05 2024 +0000, Giovanni Mascellani wrote:
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?
In that case, can you assign to r3 in l1, then overwrite it later in one flow path but not the other? I suspect this is how phi values are resolved in the hardware, but I haven't looked at the details. Maybe something to consider later, since the current code is fine for testing.