https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113138
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot
gnu.org
Last reconfirmed| |2023-12-25
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
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); })
)
)
)