sanjoy added a subscriber: sanjoy. sanjoy added a comment. Have you considered treating this as a canonicalization problem? That is, always canonicalize `(X & A) | (A ^ Y)` to `(A & X) | (A ^ Y)` (for all commutative ops)? https://reviews.llvm.org/D24419