https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110897
--- Comment #4 from JuzheZhong <juzhe.zhong at rivai dot ai> --- (In reply to Richard Biener from comment #3) > it looks like you don't support vector short logical shift? For some reason > vect_recog_over_widening_pattern doesn't check whether the demoted operation > is supported ... > > The following helps on x86_64, it disables the demotion. I think the idea > was that we eventually recognize a widening shift, so the narrow operation > itself doesn't need to be supported, but clearly that doesn't work out > when there is no such shift. > Thanks Richi. what is the "vector short logical shift" optab ? Could you give me the optab name? I am gonna try to support this in RISC-V port. > diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc > index e4ab8c2d65b..4e4191652e3 100644 > --- a/gcc/tree-vect-patterns.cc > +++ b/gcc/tree-vect-patterns.cc > @@ -3091,6 +3091,11 @@ vect_recog_over_widening_pattern (vec_info *vinfo, > if (!new_vectype || !op_vectype) > return NULL; > > + optab optab; > + if (!(optab = optab_for_tree_code (code, op_vectype, optab_vector)) > + || optab_handler (optab, TYPE_MODE (op_vectype)) == CODE_FOR_nothing) > + return NULL; > + > if (dump_enabled_p ()) > dump_printf_loc (MSG_NOTE, vect_location, "demoting %T to %T\n", > type, new_type); > > with the patch above x86 can vectorize both loops with AVX2 but not without. > > Can you confirm this helps on RISC-V as well? > > Richard, what was the idea here? Yeah. I can try it after I try "vector short logical shift" pattern.