On 31 October 2011 13:23, Jakub Jelinek <ja...@redhat.com> wrote: > On Mon, Oct 31, 2011 at 01:14:25PM +0200, Ira Rosen wrote: >> > --- gcc/tree-vect-stmts.c.jj 2011-10-28 16:21:06.000000000 +0200 >> > +++ gcc/tree-vect-stmts.c 2011-10-31 10:27:57.000000000 +0100 >> > @@ -2446,7 +2446,10 @@ vectorizable_shift (gimple stmt, gimple_ >> > optab = optab_for_tree_code (code, vectype, optab_vector); >> > if (vect_print_dump_info (REPORT_DETAILS)) >> > fprintf (vect_dump, "vector/vector shift/rotate found."); >> > - if (TYPE_MODE (op1_vectype) != TYPE_MODE (vectype)) >> > + if (!op1_vectype) >> > + op1_vectype = get_same_sized_vectype (TREE_TYPE (op1), >> > vectype_out); >> > + if (op1_vectype == NULL_TREE >> > + || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype)) >> > { >> > if (vect_print_dump_info (REPORT_DETAILS)) >> > fprintf (vect_dump, "unusable type for last operand in" >> > @@ -2480,9 +2483,28 @@ vectorizable_shift (gimple stmt, gimple_ >> > /* Unlike the other binary operators, shifts/rotates have >> > the rhs being int, instead of the same type as the lhs, >> > so make sure the scalar is the right type if we are >> > - dealing with vectors of short/char. */ >> > + dealing with vectors of long long/long/short/char. */ >> > if (dt[1] == vect_constant_def) >> > op1 = fold_convert (TREE_TYPE (vectype), op1); >> > + else if (!useless_type_conversion_p (TREE_TYPE (vectype), >> > + TREE_TYPE (op1))) >> >> What happens in case dt[1] == vect_internal_def? > > For !slp_node we can't reach this with dt1[1] == vect_internal_def, > because of: > if (dt[1] == vect_internal_def && !slp_node) > scalar_shift_arg = false; > And for slp_node I'm just giving up if type modes don't match: > >> > + { >> > + if (slp_node >> > + && TYPE_MODE (TREE_TYPE (vectype)) >> > + != TYPE_MODE (TREE_TYPE (op1))) >> > + { >> > + if (vect_print_dump_info (REPORT_DETAILS)) >> > + fprintf (vect_dump, "unusable type for last operand >> > in" >> > + " vector/vector shift/rotate."); >> > + return false; >> > + } >
Ah, OK. > BTW, even the pre-existing if (dt[1] == vect_constant_def) doesn't seem to > be 100% correct for slp_node != NULL, I think vect_get_constant_vectors > will in that case create a VECTOR_CST with the desirable vector type > (same type mode as op0's vector type mode), but the constants in the > VECTOR_CST will have a wrong type (say V4DImode VECTOR_CST with > SImode constants in its constructor). The expander doesn't ICE on it > though. Right. As you wrote before, we should probably change shift vectors creation for SLP. The patch is OK. Thanks, Ira > > Jakub >