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

            Bug ID: 113458
           Summary: Missed SLP for reduction of multiplication/addition
                    with promotion
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64-*-*

Take:
```
int f(short *a, signed char *b)
{
        int sum = 0;
        sum += a[0]*b[0];
        sum += a[1]*b[1];
        sum += a[2]*b[2];
        sum += a[3]*b[3];
        return sum;
}
```

This is not SLPed with GCC.

With `-fno-vect-cost-model` it is but in a very inefficient way.

LLVM produces:
```
        ldr     s0, [x1]
        ldr     d1, [x0]
        sshll   v0.8h, v0.8b, #0 // promote to short
        smull   v0.4s, v0.4h, v1.4h //multiply 2 shorts to ints
        addv    s0, v0.4s // do the reduction
        fmov    w0, s0
```

Which GCC should be to produce this too.

Reply via email to