Finally fixes PR6773.
Now that the backend is all done, we can finally fold it!
The canonical unfolded masked merge pattern is
(x & m) | (y & ~m)
There is a second, equivalent variant:
(x | ~m) & (y | m)
Only one of them (the or-of-and's i think) is canonical.
And if the mask is not a constant, we should fold it to:
((x ^ y) & M) ^ y
I have left out the constant handling out here, since i'm not quite sure how to properly handle that.
I can either do Builder.CreateNot(), rely on automatic deduplication, and do pointer comparison.
That will be enough for everything without undef.
But with undef i will need a undef-ignoring comparator (in Constant class?)
Or i could write a more specialized comparator, which specifically checks that one constant is ~another constant.
Suggestions welcomed. Maybe there is already such a thing, and i'm simply not aware of it?