[Bug tree-optimization/105973] Wrong branch prediction for if (COND) { if(x) noreturn1(); else noreturn2(); }
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 14 11:49:04 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105973
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In fact we get it wrong even if both branches call the same noreturn function:
if (PREDICT(n > (__PTRDIFF_MAX__ / sizeof(T))))
{
if (n > (__SIZE_MAX__ / sizeof(T)))
throw1();
throw1();
}
This is not compiled to the same code as:
if (PREDICT(n > (__PTRDIFF_MAX__ / sizeof(T))))
{
throw1();
}
even though it has identical effects.
More information about the Gcc-bugs
mailing list