Why vectorization didn't turn on by -O2
Mon May 10 12:10:17 GMT 2021
> On Mon, May 10, 2021 at 11:11:36AM +0200, Jan Hubicka wrote:
> > > 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, firstname.lastname@example.org 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.
> Huh! Will you investigate how/why this happens? Also, it probably is
> quite different on different archs. Interesting times ahead.
> > I plan to re-do the benchmarks soon now gcc11 branched.
> Great, thanks in advance, gl;hf :-)
I was referring to the very cheap model here. I think cheap model may
need some love since it seems to pick quite some code overhead and still
produce noticeably fewer speedups than dynamic. This however may be
very SPEC benchmarks centric since we tune vectorizer for years on
I am re-running benchmarks now and lets see.
More information about the Gcc-help