Dorit Nuzman wrote: >> Tim Prince writes: >> > kanishk rastogi wrote: >> > > hi all, >> > > I wanted to know if when i specify -O[0-3] flag to gcc does gcc >> > > optimize the code even violating ABI for that specific arch. >> > > If yes can i specify gcc not to violate the ABI .... >> > > I am mostly concerned witht he ABI specification which tells how to >> > > call another function.. >> > > >> > >> > Only the -Os changes the value of -mpreferred-stack-boundary, breaking >> > the ability to support vectorization or other alignment dependent code >> > in the callee. >> >> -Os breaks vectorization? That would be A Bug, for sure. Do you have >> references, Bugzilla entries, for this? >> > > I don't think -mpreferred-stack-boundary breaks vectorization, but it can > affect vectorization because vectorization is sensitive to alignment, and > the ability to force the alignment of arrays on the stack currently depends > on the preferred stack boundary. You can see > http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00202.html for more details. > > dorit > > Maybe it is too harsh to call it breakage when the vectorizer has to allow for non-alignment in cases where it shouldn't be necessary. Problems which derive from that include inconsistent results from repeating the same vectorized calculation at differing alignments (presumably only with the sum reduction vectorizations enabled only with -ffast-math), and inability to vectorize short fixed length operations. I'd have to test thoroughly extreme cases such as vectorization of double operations with -mpreferred-stack-boundary=2 (as set by -Os on 32-bit i386) to believe it can be made to work. I'll have to check gfortran to see that it doesn't contain the bug I have seen with other Fortrans, where expressions may be evaluated incorrectly in remainder calculations, causing elusive alignment dependent bugs. SSE intrinsics definitely can be broken by -Os. After several years of complaints, cygwin agreed to build binutils with stack boundary of 4 so as not to arbitrarily reduce the alignments set by normal gcc defaults.