On 01/05/15 10:44, Andrew Savchenko wrote:
On Fri, 1 May 2015 05:09:51 +0000 (UTC) Martin Vaeth wrote:
Andrew Savchenko <birc...@gentoo.org> wrote:
That's why kernel makes sure that no floating point instructions
sneaks in using CFLAGS, you may see a lot of -mno-${intrucion_set}
flags when running make -V.
So it should be sufficient that the kernel does not use "float"
or "double", shouldn't it?
No. Optimizer paths may be very unobvious, i.e. I'll not be
surprised if under some conditions vectorizer may use float
instructions for int code.
The kernel uses -O2 and several -march variants (e.g. -march=core2).
Several other options are used to prevent GCC from generating unsuitable
code.
Specifying another -march variant does not affect the optimizer though.
It only affects the code generator. If you don't modify the other CFLAGS
and only change -march, you will not get FP instructions unless you use
FP in the code.
Also, I'd be very interested to see *any* optimization that would
somehow transform integer code to FP code (note that SIMD is not FP and
is perfectly fine in the kernel.) In fact, optimizers tend to transform
FP into SIMD, at least on x86 (and other architectures that have fast
SIMD instructions.) If I inspect the generated assembly from GCC or
Clang, I cannot find FP anywhere, even for code using "float" and
"double" operations. They get converted to SIMD on modern CPUs (unless
you specify a compiler flag that tells it to use the FPU, for example if
you need 80-bit extended precision, which is supported by the x86 FPU.)