https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108583

--- Comment #5 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
> > The vectorizer has this context but since we didn't want a new IFN the 
> > context should instead be derivable in 
> > targetm.vectorize.can_special_div_by_const hook.
> 
> The vectorizer doesn't check for a widened operand zero.  In fact
> "can_special_div_by_const" doesn't suggest that widening is required.

Correct, at the moment the generalized so far as to be a generic div by
constant operation.  But the original sequence wanted to optimize a sequence
that needs more context than what was given to it.

> If the vectorizer checks that then why do we need another operand?

Because the expansion gets triggered by intrinsics code as well:

typedef unsigned __attribute__((__vector_size__ (16))) V;

static __attribute__((__noinline__)) __attribute__((__noclone__)) V
foo (V v, unsigned short i)
{
  v /= i;
  return v;
}

It's invalid to do this particular decomposition we do in AArch64, but the hook
doesn't know this.  Since the new IFN wasn't like we're just leaving the `/`
alone in the vectorizer.  But this means the expansion code, or the backend
needs to be able to check the context in which we are expanding.

We don't have an integer vector division operation. So the operation needs to
be decomposed.  And if we decompose it, then the sequence becomes too long for
combine to match and we're back where we started.

Reply via email to