https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70923
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Marc Glisse from comment #3) > (In reply to Richard Biener from comment #1) > > We have vect_recog_mult_pattern that should have triggered here but that > > only tries replacement with LSHIFT_EXPR rather than also a simple plus > > for 2 * x. > > I guess that would be something like > > --- tree-vect-patterns.c (revision 236808) > +++ tree-vect-patterns.c (working copy) > @@ -2226,7 +2226,13 @@ vect_recog_mult_pattern (vec<gimple *> * > power2_neg_val = wi::exact_log2 (wi::neg (oprnd1)); > > /* Handle constant operands that are postive or negative powers of 2. */ > - if (power2_val != -1) > + if (power2_val == 1) > + { > + pattern_stmt > + = gimple_build_assign (vect_recog_temp_ssa_var (itype, NULL), > + PLUS_EXPR, oprnd0, oprnd0); > + } > + else if (power2_val != -1) > { > shift = build_int_cst (itype, power2_val); > pattern_stmt > > and something similar for the case *-2, it may be nicer to put this new ==1 > case inside the !=-1 case (especially for power2_neg_val). But I don't think > I can easily test that, no sparc in the compile farm. It bails out before the above with the vecotr shift availability check.