Possible Phi Removal Pass?

Looking through this mailing list's archives, I've found that the most common fix attempted for removing phi instructions is to use the reg2mem pass. However I'm also finding that this does no guarantee the removal of all phi instructions.

I want to write a pass to remove phi instructions without changing register/memory usage. Does this sort of translation of phi instructions seem reasonable? :

Looking through this mailing list's archives, I've found that the most
common fix attempted for removing phi instructions is to use the
reg2mem pass. However I'm also finding that this does no guarantee the
removal of all phi instructions.

Err, I'm pretty sure it does remove all PHI's; not sure where you're
getting the idea that it doesn't.

I want to write a pass to remove phi instructions without changing
register/memory usage. Does this sort of translation of phi
instructions seem reasonable? :

[...]

There is no way to construct LLVM IR like your "Post-pass" example;
LLVM IR is SSA, so every register has precisely one definition. There
is no way to avoid PHI nodes in the general case except using memory.

-Eli

This isn't SSA form anymore. You have two assignments to %indvar and %j.02.

Sebastian