https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31531
--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The only patch which is needed now: diff --git a/gcc/match.pd b/gcc/match.pd index 37c5be9e5f4..ca6c9eff624 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4729,10 +4729,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (for cmp (simple_comparison) scmp (swapped_simple_comparison) (simplify - (cmp (bit_not@2 @0) CONSTANT_CLASS_P@1) + (cmp (nop_convert?:s (bit_not@2 @0)) CONSTANT_CLASS_P@1) (if (single_use (@2) && (TREE_CODE (@1) == INTEGER_CST || TREE_CODE (@1) == VECTOR_CST)) - (scmp @0 (bit_not @1))))) + (with { tree type1 = TREE_TYPE (@1); } + (scmp (convert:type1 @0) (bit_not @1)))))) (for cmp (simple_comparison) /* Fold (double)float1 CMP (double)float2 into float1 CMP float2. */ I will add a testcase and submit it in a few.