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

            Bug ID: 65963
           Summary: Missed vectorization of loads strided with << when
                    equivalent * succeeds
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alalaw01 at gcc dot gnu.org
  Target Milestone: ---

This testcase does not vectorize at -O3 on x86_64/-mavx or AArch64:
void
loop (int *in, int *out)
{
  for (int i = 0; i < 256; i++) {
     out[i] = in[i << 1] + 7;
  }
}

-fdump-tree-vect-details reveals:
Creating dr for *_12
analyze_innermost: failed: evolution of base is not affine.
        base_address: 
        offset from base address: 
        constant offset from base address: 
        step: 
        aligned to: 
        base_object: *_12

However, this testcase succeeds:
void
loop (int *in, int *out)
{
  for (int i = 0; i < 256; i++) {
     out[i] = in[i * 2] + 7;
  }
}

The relevant extract of -fdump-tree-vect-details showing:
Creating dr for *_12
analyze_innermost: success.
        base_address: in_11(D)
        offset from base address: 0
        constant offset from base address: 0
        step: 8
        aligned to: 256
        base_object: *in_11(D)
        Access function 0: {0B, +, 8}_1

The only difference is the multiplication:
$ diff splice{,2}.c.131t.ifcvt
27c27
<   _8 = i_19 * 2;
---
>   _8 = i_19 << 1;
$

Reply via email to