https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90094
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |uros at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But then shouldn't we do it not just for equality/non-equality comparisons
against 0x8000000000000000, but also for equality/non-equality comparisons
against 0x7fffffffffffffff or signed non-equality comparisons like >
__LONG_MAX__ - 42
or >= __LONG_MAX__ - 0x7fffff00 etc.
I mean
void fn (void);
unsigned
f1 (long a)
{
return a == -__LONG_MAX__ - 1;
}
void
f2 (long a)
{
if (a == -__LONG_MAX__ - 1)
fn ();
}
unsigned
f3 (long a)
{
return __builtin_sub_overflow_p (0, a, 0L);
}
void
f4 (long a)
{
if (__builtin_sub_overflow_p (0, a, 0L))
fn ();
}
unsigned
f5 (long a)
{
return a == __LONG_MAX__;
}
void
f6 (long a)
{
if (a == __LONG_MAX__)
fn ();
}
unsigned
f7 (long a)
{
return __builtin_add_overflow_p (a, 1, 0L);
}
void
f8 (long a)
{
if (__builtin_add_overflow_p (a, 1, 0L))
fn ();
}
unsigned
f9 (long a)
{
return a >= __LONG_MAX__ - 42;
}
void
f10 (long a)
{
if (a >= __LONG_MAX__ - 42)
fn ();
}
unsigned
f11 (long a)
{
return __builtin_add_overflow_p (a, 43, 0L);
}
void
f12 (long a)
{
if (__builtin_add_overflow_p (a, 43, 0L))
fn ();
}
unsigned
f13 (long a)
{
return a <= -__LONG_MAX__ + 42;
}
void
f14 (long a)
{
if (a <= -__LONG_MAX__ + 42)
fn ();
}
unsigned
f15 (long a)
{
return __builtin_sub_overflow_p (a, 43, 0L);
}
void
f16 (long a)
{
if (__builtin_sub_overflow_p (a, 43, 0L))
fn ();
}
The question if it should be done in the cstoredi4 and cbranchdi4 expanders, or
matched later say during combine, or peephole2.