https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85563
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Last reconfirmed|2018-04-30 00:00:00 |2021-4-15
CC| |msebor at gcc dot gnu.org
Known to fail|8.0.1 |10.2.0, 11.0, 8.3.0, 9.3.0
--- Comment #18 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirming with GCC 11.
Inverting the reachability expression:
((CONSP (Vframe_list)) ? (void) 0 : __builtin_unreachable ());
to
(!(CONSP (Vframe_list)) ? __builtin_unreachable () : (void) 0);
or changing it to a corresponding if statement avoids the warning and improves
the emitted code, implying there is a missed optimization opportunity there
somewhere.
I also reduced the test from comment #6 a bit further to make it easier to
read:
struct A
{
struct A *p, *q;
};
extern void *p;
inline _Bool
f (void* a)
{
return ((__INTPTR_TYPE__) (a) & ~(- (1 << 3))) == 3;
}
inline struct A *
g (void* a)
{
return (struct A *)((char *)a - 3);
}
extern void* foo (void*);
void bar (void)
{
#if NOWARN
if (!f (p))
__builtin_unreachable ();
#else
f (p) ? (void)0 : __builtin_unreachable ();
#endif
void* q;
for (void *r = p; f (r) && ((q = g (r)->p), 1); r = g (r)->q)
;
foo (q);
}