https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111718
Ivan Sorokin <vanyacpp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vanyacpp at gmail dot com
--- Comment #1 from Ivan Sorokin <vanyacpp at gmail dot com> ---
GCC does the optimization if the return from the function is replaced with
__builtin_unreachable:
unsigned n1, n2;
void func1(unsigned a)
{
if (a <= 10 || a >= 20)
__builtin_unreachable();
n1 = a + a;
n2 = (a + a)/a;
}
func1(unsigned int):
mov DWORD PTR n2[rip], 2
add edi, edi
mov DWORD PTR n1[rip], edi
ret
https://godbolt.org/z/Tjsz6neTs
Perhaps this issue has the same underlying cause as the PR80015.