https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107881
--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> --- For the ^/!= case here are the missing optimizations (note == can be handled too): ``` int ltgtxor(int a, int b) { _Bool c = a < b; _Bool d = a > b; return c ^ d; // a != b } int lteqxor(int a, int b) { _Bool c = a < b; _Bool d = a == b; return c ^ d; // a <= b (basically | here) } int ltnexor(int a, int b) { _Bool c = a < b; _Bool d = a != b; return c ^ d; // a > b } int legexor(int a, int b) { _Bool c = a <= b; _Bool d = a >= b; return c ^ d; // a != b } int leeqxor(int a, int b) { _Bool c = a <= b; _Bool d = a == b; return c ^ d; // a < b } int lenexor(int a, int b) { _Bool c = a <= b; _Bool d = a != b; return c ^ d; // a >= b } ``` Match pattern I think: ``` (for op (bit_xor ne) (for cmp1 (lt lt lt le le le) cmp2 (gt eq ne ge eq ne) rcmp (ne le gt ne lt ge) (simplify (op:c (cmp1:c @0 @1) (cmp2:c @0 @1)) (rcmp @0 @1)))) ``` For eq: ``` (for cmp1 (lt lt lt le le le) cmp2 (gt eq ne ge eq ne) rcmp (eq ge le eq ge lt) (simplify (eq:c (cmp1:c @0 @1) (cmp2:c @0 @1)) (rcmp @0 @1))) ``` Both of these this check though: (INTEGRAL_TYPE_P (TREE_TYPE (@0)) || POINTER_TYPE_P (TREE_TYPE (@0)))