On Thu, Jul 09, 2015 at 11:14:01AM +0200, Richard Biener wrote:
> > @@ -2764,6 +2769,93 @@ vectorizable_simd_clone_call (gimple stm
> >             || thisarginfo.dt == vect_external_def)
> >            && POINTER_TYPE_P (TREE_TYPE (op)))
> >     thisarginfo.align = get_pointer_alignment (op) / BITS_PER_UNIT;
> > +      /* Addresses of array elements indexed by GOMP_SIMD_LANE are
> > +    linear too.  */
> > +      if (POINTER_TYPE_P (TREE_TYPE (op))
> > +     && !thisarginfo.linear_step
> > +     && !vec_stmt
> > +     && thisarginfo.dt != vect_constant_def
> > +     && thisarginfo.dt != vect_external_def
> > +     && loop_vinfo
> > +     && !slp_node
> > +     && TREE_CODE (op) == SSA_NAME)
> > +   {
> > +     def_stmt = SSA_NAME_DEF_STMT (op);
> > +     if (is_gimple_assign (def_stmt)
> > +         && gimple_assign_rhs_code (def_stmt) == POINTER_PLUS_EXPR
> > +         && is_gimple_min_invariant (gimple_assign_rhs1 (def_stmt)))
> > +       {
> > +         tree base = gimple_assign_rhs1 (def_stmt);
> > +         HOST_WIDE_INT linear_step = 0;
> > +         tree v = gimple_assign_rhs2 (def_stmt);
> > +         while (v && TREE_CODE (v) == SSA_NAME)
> 
> Hmm, this looks like it could be split out to a function.

Ok, will try that.

> > +                   base = fold_build2 (POINTER_PLUS_EXPR,
> > +                                       TREE_TYPE (base), base, t);
> > +                   v = gimple_assign_rhs1 (def_stmt);
> > +                   continue;
> 
> what about MINUS_EXPR?  I suppose you only handle stuff that's
> produced by get_inner_reference here?

This is meant to be used with the "omp simd array" vars, and what
is produced by Marek's pass from those, so something that originally
in the code are simple scalar or aggregate
vars, I'm only handling + with a constant bias, wouldn't subtraction
be folded into addition of negative constant anyway?
This code isn't for correctness, but optimization, if it doesn't detect
something is linear, even when it is, it can simply not be vectorized or
vectorized less efficiently through some other simd clone.
> 
> > +                 case MULT_EXPR:
> > +                   t = gimple_assign_rhs2 (def_stmt);
> > +                   if (linear_step
> > +                       || !tree_fits_shwi_p (t)
> > +                       || integer_zerop (t))
> > +                     {
> 
> So no VLAs... (I understand this code is for correctness?)

VLAs aren't added as "omp simd array" ever, I punt on them early
(set safelen to 1).

        Jakub

Reply via email to