From: Josh V. <ho...@na...> - 2001-03-26 19:47:53
|
David Konerding <de...@ko...> writes: > > But with '-fstrict-aliasing', which was used in my auto-generated > > Makefile for Mesa, the results for sqrt are for some numbers up to > > 10 times greater than the once generated by gl_sqrt, while the > > speed for normal sqrt is still higher. > > Did you read the man page for gcc and learn what -fstrict-aliasing > does? I wouldn't use that feature for math-intensive routines. I don't know of any reason why math-intensive routines would be affected by -fstrict-aliasing. However, it does matter for what gcc calls 'type punning' (accessing one type as if it were another type), which Mesa does a lot of. GCC will handle this ok: int get_float_bits(float f) { union { int i; float f; } n; n.f = f; return n.i; } But it is allowed to screw this up: int get_float_bits(float f) { return *(int *)&f; } Most of the type puns in mmath use unions, but it looks like there are several occurrences of *(type *)&var scattered around (one is at the begining of gl_sqrt()). Someone should get rid of them so we can compile with strict aliasing. Josh |