This code was replicated two additional times to handle commuted cases, but I think a commutable matcher can take care of it.
Details
Diff Detail
Event Timeline
Looks like good clean-up, but we only have 2 existing tests for these folds. There should be 4 commuted variants?
It's an independent change, but if we used m_APInt here, the code would be cleaner still and automatically work with splat vectors. You could make the additional commuted tests use vector types to serve double-duty if you want to add coverage for both of those changes.
Side note regarding commutation: just above here, simplifyAndOrOfICmps() calls simplifyPossiblyCastedAndOrOfICmps() with the params swapped to handle commutation, but some of the folds under there (ConstantRange checks at least) don't need to be commuted. Barring an inlining and analysis miracle, we're probably doing extra work for no reason on those, so untangling that would save compile-time.
So should I do the m_APInt change first so I can plug the commuted test hole with the vector tests?
If we can make that work too, that would be great. :)
I don't have a preference about whether we change this in one step or more. Whatever seems easier to you. As long as we have at least a couple more tests, we should be sure that it all works as expected.