[Bug middle-end/126410] New: vectorizer aligns 16-byte array to 64byte

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

            Bug ID: 126410
           Summary: vectorizer aligns 16-byte array to 64byte
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

[hjl@gnu-tgl-3 pr126403]$ cat foo.c
#define N 4

typedef struct { float values[N]; } vector;

extern vector v;

extern void foo (vector *);

void
func (vector a, vector b)
{
  vector r;
  for (int i = 0; i < N; i++)
    r.values[i] = a.values[i] * b.values[i];
  foo (&r);
}
[hjl@gnu-tgl-3 pr126403]$ gcc -O2 -S foo.c -march=x86-64-v4 
[hjl@gnu-tgl-3 pr126403]$ cat foo.s
        .file   "foo.c"
        .text
        .p2align 4
        .globl  func
        .type   func, @function
func:
.LFB0:
        .cfi_startproc
        vpextrq $1, %xmm4, %rdx
        vmovdqa %xmm0, %xmm4
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        vpinsrq $1, %rdx, %xmm4, %xmm4
        vpextrq $1, %xmm5, %rdx
        vmovdqa %xmm2, %xmm5
        vpinsrq $1, %rdx, %xmm5, %xmm5
        vpunpcklqdq     %xmm1, %xmm4, %xmm4
        vpunpcklqdq     %xmm3, %xmm5, %xmm5
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        andq    $-64, %rsp    <<< Not needd.
        vmulps  %xmm5, %xmm4, %xmm1
        subq    $64, %rsp
        movq    %rsp, %rdi
        vmovaps %xmm1, (%rsp)
        call    foo
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE0:
        .size   func, .-func
        .ident  "GCC: (GNU) 16.1.1 20260703 (Red Hat 16.1.1-4)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-tgl-3 pr126403]$ 



Breakpoint 1, ensure_base_align (dr_info=0x4f58288)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/tree-vect-stmts.cc:7189
7189            DR_TARGET_ALIGNMENT (dr_info).to_constant () * BITS_PER_UNIT;
Missing rpms, try: dnf --enablerepo='*debug*' install
isl-debuginfo-0.16.1-24.0.fc44.x86_64 libmpc-debuginfo-1.4.1-1.fc44.x86_64
mpfr-debuginfo-4.2.2-3.fc44.x86_64 gmp-debuginfo-6.3.0-5.0.fc44.x86_64
zlib-ng-compat-debuginfo-2.3.3-3.fc44.x86_64
libzstd-debuginfo-1.5.7-5.fc44.x86_64 glibc-debuginfo-2.43-7.0.fc44.x86_64
(gdb) next
7191          if (decl_in_symtab_p (base_decl))
(gdb) p align_base_to
$1 = 512
(gdb) 

Why does DR_TARGET_ALIGNMENT (dr_info).to_constant () return 64 bytes?
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.