https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110897
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-08-04 Target|riscv |riscv, x86_64-*-* CC| |rsandifo at gcc dot gnu.org Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Blocks| |53947 Component|target |tree-optimization --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- 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. 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? Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations