https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19832
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Xor should be handled too: ``` int f_xor(int i, int j) { if (i!=j) return i ^ j; return 0; } `` ior and and should be handled ``` int f_or(int i, int j) { if (i!=j) return i | j; return i; // could be j not just i } int f_and(int i, int j) { if (i!=j) return i & j; return i; // could be j not just i } ``` So can plus and multiply: ``` int f_add(int i, int j) { if (i!=j) return i + j; return i+i; } int f_mult(int i, int j) { if (i!=j) return i * j; return i*i; } ``` Note clang handles all of these except for f_add. f_mult might be handled via the pull `i*` out of the conditional and then you have `i!=j?j:i` which then will be reduced to j (that is they don't pattern match f_mult). They don't have pattern matching for f_add either and `i+i` will change to `i*2` and not pulled out of the condition.