Re: Why vectorization didn't turn on by -O2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Sun, 9 May 2021, Segher Boessenkool wrote:
> 
> > On Sun, May 09, 2021 at 12:54:08AM +0800, Xi Ruoyao via Gcc-help wrote:
> > > On Sat, 2021-05-08 at 20:07 +0800, 172060045@xxxxxxxxxx wrote:
> > > > Recently I noticed that gcc -O2 didn't turn on vectorization
> > > > optimization, 
> > > > which it turns on in clang -O2.
> > > > 
> > > > Does GCC think it involves the trade-off of space speed, or other
> > > > considerations?
> > 
> > -O2 is for optimisations that (almost) never degrade code quality.  -O3
> > is for those that are only beneficial "on average".
> 
> In particular -O2 is a balance of compile-time, generated code size
> and resulting performance.  Vectorization with the -O2 default
> cost model of "cheap" tends to mostly increase the first and the second
> whilst only moderately affecting the last.

Last time I ran -O2 with cheap model enabled, the code size was actually
decreasing at average for SPEC which was a bit of a surprise.

I plan to re-do the benchmarks soon now gcc11 branched.

Honza
> 
> It's all of course hugely dependent on the source base you are
> working with.
> 
> Richard.
> 
> > > It's just a decision I think.  The "original" reason may be that
> > > vectorization can make code *slower* on some cases.
> > 
> > Yup.  Vectorisation always causes hugely different code.
> > 
> > > There was some discussion about enabling -ftree-loop-vectorization at -
> > > O2 for x86, but that was too late (for GCC 9):
> > 
> > AFAIK the current plan is to enable vectorisation at -O2 with a more
> > conservative cost model.  This will be a generic change, for all
> > architectures, and hopefully will arrive in GCC 12.
> > 
> > 
> > Segher




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux