https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107285
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- No, the generated code is just fine. At -O2, bar is inlined into main. So we have unsigned int a = __builtin_constant_p (3) ? 13 : 60; and 3 is constant. In the out of line copy of bar, value1 is a function parameter, so __builtin_constant_p evaluates to false. As I said, what is bad is the testcase, the above isn't how __builtin_constant_p should be used. I'd suggest you look in /usr/include/ or other codebases how one uses the builtin...