https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78879
--- Comment #3 from Markus Trippelsdorf <trippels at gcc dot gnu.org> --- (In reply to Yuan Pengfei from comment #2) > (In reply to Markus Trippelsdorf from comment #1) > > See discussion in PR72785. > > I am using GCC 6.2.1. Is it the same problem? Yes, I think so. The compiler is under no obligation to optimize the ____ilog2_NaN call away. It looks like a kernel bug.