[Bug tree-optimization/126544] New: Quadraticness in SLP vectorisation

"ktkachov at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126544

            Bug ID: 126544
           Summary: Quadraticness in SLP vectorisation
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

This needs a Python script to generate the offending form:
#!/usr/bin/env python3
"""Emit the basic block that makes BB SLP quadratic.

  python3 04-slp-quadratic.py 3200 > t.c
  gcc -O1 -ftree-slp-vectorize -fvect-cost-model=unlimited \
      -march=armv8.2-a+sve -ftime-report -S -o /dev/null t.c

At n = 3200 the "tree slp vectorization" line reads 16.73 s and 1261 MB.
Doubling n multiplies both by four.  Inserting an
__asm__ volatile ("" ::: "memory") every 64 stores splits the SLP region and
makes both perfectly linear, which is what identifies the region length as
the quadratic term.
"""
import sys

n = int(sys.argv[1]) if len(sys.argv) > 1 else 3200
print("int a[%d], b[%d], c[%d];" % (n + 8, n + 8, n + 8))
print("void f (void) {")
for i in range(n):
    print("  a[%d] = b[%d] * c[%d] + %d;" % (i, i, i, i))
print("}")

Doing this on an aarch64 machine gives this line in -ftime-report:
tree slp vectorization             :  14.57 ( 66%)   0.09 ( 47%)  14.66 ( 65%) 
1883M ( 95%)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.