r/Compilers • u/Majestic-Lack2528 • May 24 '26
Phi to block parameters
Is there a way to convert phi nodes to basic block parameters?
21
Upvotes
r/Compilers • u/Majestic-Lack2528 • May 24 '26
Is there a way to convert phi nodes to basic block parameters?
View all comments
Show parent comment
11
u/Rusky May 24 '26
Basic block parameters are just another notation for phi nodes, that looks a little more like a continuation-passing style IR. They are used by, for example, Cranelift.
For the OP: Yes, you replace each phi node with a parameter on its containing block, and move each operand of that phi node to become an operand of the terminator (jump, branch) instruction in its associated predecessor block.