Overview
OpPhi instruction is used to select some result id based on the previous basic block that was executed. We can replace the use of an OpPhi instruction’s result id with the corresponding operand of the OpPhi instruction. This transformation can provide an opportunity for the previous transformation to move the instruction between basic blocks.
Implementation
The implementation of this transformation should follow the domination rules of the SPIR-V language. Particularly, if the instruction of interest uses a result id of some instruction from the same basic block that is not an OpPhi, we cannot apply this transformation to that instruction. Otherwise, we will have to insert a copy of this instruction into every preceding basic block, adjust operands to all those inserted instructions s.t. the result id of every OpPhi instruction is replaced with the corresponding operand to that instruction and replace the initial instruction with the OpPhi.