[Bug tree-optimization/105983] Failure to optimize (b != 0) && (a >= b) as well as the same pattern with binary and
rearnsha at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 15 14:13:56 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105983
--- Comment #5 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> --- gcc/match.pd.jj 2022-06-15 12:52:04.640981511 +0200
> +++ gcc/match.pd 2022-06-15 15:28:55.916225336 +0200
> @@ -2379,14 +2379,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>
> /* y == XXX_MIN || x < y --> x <= y - 1 */
> (simplify
> - (bit_ior:c (eq:s @1 min_value) (lt:s @0 @1))
> + (bit_ior:c (eq:s @1 min_value) (lt:cs @0 @1))
> (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> && TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
> (le @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))
>
> /* y != XXX_MIN && x >= y --> x > y - 1 */
> (simplify
> - (bit_and:c (ne:s @1 min_value) (ge:s @0 @1))
> + (bit_and:c (ne:s @1 min_value) (ge:cs @0 @1))
> (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> && TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
> (gt @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))
>
> fixes this.
But doesn't that regress
bool f(unsigned a, unsigned b)
{
return (b != 0) & (a >= b);
}
More information about the Gcc-bugs
mailing list