For a specific pattern of type or(phi1, phi2), where the other use of phi is an "icmp ne with 0", we can reuse these icmps to form the argument to or. This helps reuse the icmps, reduce or to and, and also bring icmps close to phi for further optimizations.
Alive link https://alive2.llvm.org/ce/z/eAyHWm
This seems very much so like a DAG type fold where you are basing the decision on existing expressions.
phi doesn't exist in backend (dagcombiner) so its a bit tricky.
@nikic, any place this can be put where it doesn't req iterating the use-list?
generally in instcombine we get our duplication by just blindly canoniclizing to a standard format.
Is there a regression if you blindly do the transform?