https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119086
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note the documentation of __builtin_constant_p says this is how it should work. As __builtin_constant_p arguments side effects will be disregarded.