On Sat, Feb 3, 2018 at 12:30 AM, Bill Schmidt <wschm...@linux.vnet.ibm.com> wrote: > Hi, > > The test g++.dg/vect/slp-pr56812.cc is somewhat fragile and is currently > failing > on several targets. PR81038 notes that this began with r248678, which stopped > some inferior peeling solutions from preventing vectorization that could be > done > without peeling. I observed that for powerpc64le, r248677 vectorizes the code > during SLP, but r248678 vectorizes it during the loop vectorization pass. > Which > pass does the vectorization is quite dependent on cost model, which for us is > a > quite close decision. In any case, the important thing is that the code is > vectorized, not which pass does it. > > This patch prevents the test from flipping in and out of failure status > depending > on which pass does the vectorization, by testing the final "optimized" dump > for > the expected vectorized output instead of relying on a specific vectorization > pass dump. > > By the way, the test case somehow had gotten DOS/Windows newlines into it, so > I removed those. The ^M characters disappeared when I pasted into this > mailer, > unfortunately. Anyway, that's the reason for the full replacement of the > file. > The only real changes are the dg-final directives and the documentation of the > expected output. > > Verified on powerpc64le-unknown-linux-gnu. Is this okay for trunk?
Hmm. That removes the existing XFAIL. Also wouldn't it be more elegant to do the following? This makes the testcase pass on x86_64, thus committed ;) Richard. 2018-02-08 Richard Biener <rguent...@suse.de> * g++.dg/vect/slp-pr56812.cc: Allow either basic-block or loop vectorization to happen. Index: gcc/testsuite/g++.dg/vect/slp-pr56812.cc =================================================================== --- gcc/testsuite/g++.dg/vect/slp-pr56812.cc (revision 257477) +++ gcc/testsuite/g++.dg/vect/slp-pr56812.cc (working copy) @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-require-effective-target vect_float } */ /* { dg-require-effective-target vect_hw_misalign } */ -/* { dg-additional-options "-O3 -funroll-loops -fvect-cost-model=dynamic" } */ +/* { dg-additional-options "-O3 -funroll-loops -fvect-cost-model=dynamic -fopt-info-vec" } */ class mydata { public: @@ -13,10 +13,7 @@ public: void mydata::Set (float x) { - for (int i=0; i<upper(); i++) + /* We want to vectorize this either as loop or basic-block. */ + for (int i=0; i<upper(); i++) /* { dg-message "note: \[^\n\]* vectorized" } */ data[i] = x; } - -/* For targets without vector loop peeling the loop becomes cheap - enough to be vectorized. */ -/* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "slp1" { xfail { ! vect_peeling_profitable } } } } */ > Thanks, > Bill > > > 2018-02-02 Bill Schmidt <wschm...@linux.vnet.ibm.com> > > * g++.dg/vect/slp-pr56812.cc: Convert from DOS newline characters > to utf-8-unix. Change to scan "optimized" dump for indications > that the code was vectorized. > > > Index: gcc/testsuite/g++.dg/vect/slp-pr56812.cc > =================================================================== > --- gcc/testsuite/g++.dg/vect/slp-pr56812.cc (revision 257352) > +++ gcc/testsuite/g++.dg/vect/slp-pr56812.cc (working copy) > @@ -1,22 +1,31 @@ > -/* { dg-do compile } */ > -/* { dg-require-effective-target vect_float } */ > -/* { dg-require-effective-target vect_hw_misalign } */ > -/* { dg-additional-options "-O3 -funroll-loops -fvect-cost-model=dynamic" } > */ > - > -class mydata { > -public: > - mydata() {Set(-1.0);} > - void Set (float); > - static int upper() {return 8;} > - float data[8]; > -}; > - > -void mydata::Set (float x) > -{ > - for (int i=0; i<upper(); i++) > - data[i] = x; > -} > - > -/* For targets without vector loop peeling the loop becomes cheap > - enough to be vectorized. */ > -/* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "slp1" { > xfail { ! vect_peeling_profitable } } } } */ > +/* { dg-do compile } */ > +/* { dg-require-effective-target vect_float } */ > +/* { dg-require-effective-target vect_hw_misalign } */ > +/* { dg-additional-options "-O3 -funroll-loops -fvect-cost-model=dynamic > -fdump-tree-optimized" } */ > + > +class mydata { > +public: > + mydata() {Set(-1.0);} > + void Set (float); > + static int upper() {return 8;} > + float data[8]; > +}; > + > +void mydata::Set (float x) > +{ > + for (int i=0; i<upper(); i++) > + data[i] = x; > +} > + > +/* { dg-final { scan-tree-dump "vect_cst__\[0-9\]* = " "optimized" } } */ > +/* { dg-final { scan-tree-dump-times "= vect_cst__\[0-9\]*;" 2 "optimized" } > } */ > + > +/* Expected vectorized output is something like: > + > + <bb 2> [11.11%]: > + vect_cst__10 = {x_5(D), x_5(D), x_5(D), x_5(D)}; > + MEM[(float *)this_4(D)] = vect_cst__10; > + MEM[(float *)this_4(D) + 16B] = vect_cst__10; > + return; > + > + Could be vectorized either by the "vect" or the "slp" pass. */ >