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

            Bug ID: 126817
           Summary: (BB) vectorization of loads from two (or more)
                    different groups
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
            Blocks: 53947
  Target Milestone: ---

double x[2], y[2], z[2];

void foo ()
{
  x[0] = y[0] + y[1];
  x[1] = z[0] + z[1];
}

is one of the simplest testcases illustrating the issue.  Building from
{ x[0], x[1] } we run into addition arguments of mixed load groups like
{ y[0], z[0] } which we do not support.

But the case of two groups can be code generated by loading from two
groups and then appling a permute.

x86 can do the above with haddpd, but that's of course a special case.
Two shuffles are needed in the canonical case which might or might not
be offset by the ability to perform two vector loads instead of four
scalar loads and a vector add.

We have recently added the ability to SLP discover an operand from two
different existing vectors, that's a similar case.

For larger load groups the question is how to align the performed vector
loads in case only a subset of elements are visible in an SLP operand.
The natural thing is to load N elements from each group for a permute
result of N elements, aligned to N when that is a power of two.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

Reply via email to