https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112628
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- For signed, it is just true. That is: ``` int f(int a) { return (~a) < -a; } int f0(int a) { return (a) > ~(-a); } ``` Are the same. In fact we can optimize even more: ``` int feq(int a) { return (~a) == -a; } ``` is always false for both signed and unsigned types. So we just do `~a CMP -a` -> `(a - 1) CMP a` for all types. Which is what we do for: `/* Fold ~X op ~Y as Y op X. */` So it is just ``` /* Fold ~X op -Y as (~(-Y)) op X. or `(Y-1) op X` */ (for cmp (simple_comparison) (simplify (cmp:c (bit_not @0) (negative @1)) (cmp (plus @1 { build_minus_one_cst (TREE_TYPE (@0)); }) @0))) ```