[PATCH] fix PR middle-end/22480

Dorit Naishlos DORIT@il.ibm.com
Sat Sep 10 15:44:00 GMT 2005





Uros Bizjak <ubizjak@gmail.com> wrote on 10/09/2005 02:02:20 PM:
> Richard Henderson wrote:
>
> >>+     optab_op2_mode = insn_data[icode].operand[2].mode;
> >>+     if (VECTOR_MODE_P (vec_mode)
> >>+         && !VECTOR_MODE_P (optab_op2_mode)
> >>+         && (dt == vect_constant_def
> >>+        || dt == vect_invariant_def))
> >>
> >>
> >I must be missing something.  At what point do you fail the
transformation
> >because op2 is *not* invariant?
> >
> >
> A couple of lines above, there is a loop that checks all tree operands
> with 'vect_is_simple_use (..., &dt)'. At the check quoted above, dt
> holds the definition of  the last operand, which is just what we need.
>
> This optimization was suggested by Dorit in her earlier message:
>
> >(by the way, vect_is_simple_use is already called earlier in that
function,
> >and the last value of 'dt' should hold the information you need).
> >

Yes, but as Richard pointed out, you still need to fail vectorization if
you find that the vec_mode requires invariant argument, and 'dt' (def type)
is not constant/invariant. I didn't notice this when I looked at the patch.
Your patch will fail on this testcase:

void convert_32_to_8(void)
{
  static unsigned bm[16];
  int am[16];
  int j;
  for (j=0; j<16;j++)
    bm[j]<<=am[j];
}

You need to add something along these lines before the tranform part in
vectorizable_operation:

  if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
    {
      optab_op2_mode = insn_data[icode].operand[2].mode;
      if (VECTOR_MODE_P (vec_mode)
          && !VECTOR_MODE_P (optab_op2_mode)
          && (dt != vect_constant_def
              && dt != vect_invariant_def))
        {
          if (vect_print_dump_info (REPORT_DETAILS))
            fprintf (vect_dump, "operand mode requires invariant
argument.");
          return false;
        }
    }

dorit


> Uros.
>



More information about the Gcc-patches mailing list