https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113138
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > Actually the following list is correct: > signed > X s< ~X --> X s< 0 > X s<= ~X --> X s< ~X --> X s< 0 > > X s> ~X --> X s> 0 > X s>= ~X --> X s> ~X --> X s> 0 > > unsigned: > X u< ~X --> X u> SIGNBIT_OF(X) > X u<= ~X --> X u< ~X --> X u> SIGNBIT_OF(X) > > X u> ~X --> X u< SIGNBIT_OF(X) > X u>= ~X --> ~X u> X --> X u< SIGNBIT_OF(X) > > So the correct idea is this: > (for (cmp lt le gt ge) > (rcmp gt gt lt lt) > (simplify > (cmp @0 @1) > (with { bool wascmp; } > (if (bitwise_inverted_equal_p (@0, @1, wascmp) > && (!wascmp || element_precision (type) == 1)) > (with { > tree inner_type = TREE_TYPE (@0); > int precision = TYPE_PRECISION (inner_type); > // the min value here is in the opposite signedness. > auto ncst = wi::min_value (precision, TYPE_UNSIGNED (inner_type) ? > SIGNED : UNSIGNED); > } > (rcmp @0 { wide_int_to_tree (inner_type, ncst); }) > ) > ) > ) Will something then fold it further if it is actually ~X s< X (because the above would then fold it into ~X s< 0)?