PHI incoming blocks order

Hello,

Is it a convenient way except of somehow iterating from one block to another to find from which block I have initial incoming value and from which I have a changing incoming value (this is only for phi nodes with two incoming blocks)? Dominator tree requires to know one block and one block edge…this is not what I want. Is it valid to take two first instructions from two incoming blocks and see what dominates what?

You can use Loop::contains() to figure out whether a basic block is inside a loop. I think that's what you're looking for?

-Eli

I would compare depths, incoming block still might be inside a loop (nested loops).

You could also just check to see if the block belongs to the same loop as the blocks in PHI.

Dominator tree does not require this, actually :wink:
It will happily take two blocks?

Yes, seems that this is the most convenient one. Thank you!