https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102684
--- Comment #3 from Kevin K <xkeviota at gmail dot com> --- (In reply to Andrew Pinski from comment #2) > (In reply to Richard Biener from comment #1) > > ISTR that clang evaluates constexpr declared things opportunistically as > > constexpr even when that is not required (your find_gcd<>(ints) call is not > > in such a context). > > I don't think that is the case here. > > First issue is the standard GCC knows main is only called once so inlining > is less. This is expected and can be ignored. Just rename main to f and > things will improve right away. > > The second issue I am trying to figure out but there seems like some missed > optimization dealing how many interations the loop is and if the loop is > small enough. The generated assembly is the same with or without the constexpr modifier, so yeah it does not seem to be that.