Observing cases where folding a icmp into phi can be beneficial. Particularly if the above fold results in the icmp argument of type BinaryOperator, it may enable more folding.
Need to understand if there is reason why the folding of icmp into phi happens within the same BB only.
Can this be done under additional checks.
Ran all tests. Looks Ok to me.
I don't think this special case make sense. Either we allow this, or we don't. There is no reason to believe that this is beneficial for just binary operators -- it just happens that this allows follow-on folds in your specific example.
I am open to dropping the check entirely, if we don't see any significant regressions from that.