This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How do you get the benefit of -fstrict-aliasing?


I've decided to try to contribute modifications to the the C code that is generated by the Gambit Scheme->C compiler so that (a) it doesn't have any aliasing violations and (b) more aliasing distinctions can be made (the car and cdr of a pair don't overlap with the entries of a vector, etc.). This was in response to a measured 20% speedup with some numerical code with -fstrict-aliasing instead of -fno-strict-aliasing, nearly all of which came because gcc then knew that stores to a vector of doubles didn't change the values of variables on the stack.

Part (a) is essentially a non-issue for user-written code, since the only aliasing problems of which I am aware are in the bignum library, so as a preliminary test I added -fstrict-aliasing to the gcc command line and reran the benchmark suite on a 2GHz G5. To my surprise, while there were some improvements, the -fstrict-aliasing option led to slower code overall, in some cases quite severely (7.014 seconds to 11.794 seconds, for example), and, perhaps not surprisingly, compilation times were significantly longer. This was true both with Apple's 4.0.1 and FSF 4.1.2.

So I'm wondering whether certain options have to be included on the command line to get the benefits of -fstrict-aliasing. The current command line is

gcc -mcpu=970 -m64 -no-cpp-precomp -Wall -W -Wno-unused -O1 -fno- math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing - fwrapv -fexpensive-optimizations -fforce-addr -fpeephole2 -falign- jumps -falign-functions -fno-function-cse -ftree-copyrename -ftree- fre -ftree-dce -fregmove -fgcse-las -freorder-functions -fcaller- saves -fno-if-conversion2 -foptimize-sibling-calls -fcse-skip-blocks - funit-at-a-time -finline-functions -fomit-frame-pointer -fPIC -fno- common -bundle -flat_namespace -undefined suppress -fstrict-aliasing

where the optimizations between -fwrapv (which is no longer necessary, I should remove that) and -fstrict-aliasing were chosen by some experiments with genetic algorithms.

I didn't think that adding aliasing information could lead to worse code. So I'm wondering how to use that aliasing information more effectively to get better code.

Brad


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]