https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95699
--- Comment #8 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> --- (In reply to Jakub Jelinek from comment #6) > I don't see why that should be considered a bug. > All the tests are using __builtin_constant_p in a way that it wasn't > designed for, where it changes the behavior of the program whether it > evaluates to 0 or 1. Well, this was just meant to be a simplified testcase and to easily see whether __builtin_constant_p gave true or false. But in GMP's longlong.h file (used by GNU MPFR), there is similar code for aarch64, where the assembly code is different whether the variable is regarded as a constant or not: #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (bl) && -(UDItype)(bl) < 0x1000) \ __asm__ ("adds\t%1, %x4, %5\n\tsbc\t%0, %x2, %x3" \ : "=r,r" (sh), "=&r,&r" (sl) \ : "rZ,rZ" ((UDItype)(ah)), "rZ,rZ" ((UDItype)(bh)), \ "r,Z" ((UDItype)(al)), "rI,r" (-(UDItype)(bl)) __CLOBBER_CC);\ else \ __asm__ ("subs\t%1, %x4, %5\n\tsbc\t%0, %x2, %x3" \ : "=r,r" (sh), "=&r,&r" (sl) \ : "rZ,rZ" ((UDItype)(ah)), "rZ,rZ" ((UDItype)(bh)), \ "r,Z" ((UDItype)(al)), "rI,r" ((UDItype)(bl)) __CLOBBER_CC);\ } while(0); The assembly code is actually buggy in the "if" case (this was how one could find out that there was a difference between GCC 9, where the "if" case was selected, and GCC 10, where the "else" case was selected), but I doubt that GCC is aware about this bug: https://sympa.inria.fr/sympa/arc/mpfr/2020-06/msg00052.html https://sympa.inria.fr/sympa/arc/mpfr/2020-06/msg00059.html I suppose that the general goal of this test using __builtin_constant_p is to have faster assembly code when some value is known at compile time. So the intent (with the fixed assembly code[*]) is to have the same behavior, but have faster code if possible. This is what we got with GCC 9, but this is no longer the case with GCC 10. [*] https://gmplib.org/list-archives/gmp-bugs/2020-June/004807.html