https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78879
--- Comment #5 from Yuan Pengfei <coolypf at qq dot com> --- (In reply to Markus Trippelsdorf from comment #3) > (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. I don't think so. In this case, the value of sector_size is constant (256, 512, 1024, 2048, 4096) and the ____ilog2_NaN call can be optimized away. It is after enabling the -fprofile-generate option when the compiler thinks the ____ilog2_NaN call can not be optimized away. Reference source code: http://lxr.free-electrons.com/source/drivers/scsi/sd.c?v=3.10#L2163