This extends the existing logic for propagating constant expressions in an analogous manner for what we do across basic blocks. The core point is that we chose some order of operands, and canonicalize uses towards that one.
The heuristic used is inspired by the one used across blocks; in a follow up change, I'd like to common them so that the cross block version uses the slightly stronger ordering herein. If preferred, I can weaken this one to match the cross block, then strengthen both in a single patch.
As noted by the TODOs in the code, there's a good amount of room for improving the existing code and making it more powerful. Unless there's strong objection, I'd like to land this first, then iterate. I am willing to commit to the findLeader change, and *maybe* the general restructure of propagateEqualities (depending on how much that snowballs - the tests are *super fragile*).
could just be something like the snippet below, which might be short & explicit enough to have inline.