Bug 60989 - automatic increase of global array for vectorization doesn't work due to flag_section_anchors==0
Summary: automatic increase of global array for vectorization doesn't work due to flag...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-28 15:20 UTC by Andi Kleen
Modified: 2014-04-29 00:17 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andi Kleen 2014-04-28 15:20:55 UTC
Target x86_64-linux

Following simple test case:

#define N 64
#define ALIGN // __attribute__((aligned(64)))
int a[N] ALIGN;
int b[N] ALIGN;

main()
{
        int i;
        for (i = 0; i < N; i++)
                a[i] = b[i] + 1;
}

If I leave the ALIGN commented out  I get really horrible manual alignment prologue code like
-O3 -mavx512f

   .cfi_startproc
        movl    $a, %eax
        andl    $63, %eax
        shrq    $2, %rax
        negq    %rax
        andl    $15, %eax
        je      .L7
        movl    b(%rip), %edi
        cmpl    $1, %eax
        leal    1(%rdi), %edx
        movl    %edx, a(%rip)
        je      .L8
...
   lots of repeats upto 63


With ALIGN it's a nice short perfectly vectorized loop.

It seems the automatic alignment of global variables doesn't work anymore.

I checked the increase_alignment/ipa_increase_alignment pass in tree-vectorize.c and both don't run because flag_section_anchors is 0 in the gate.

I'm not fully sure what the flag means?
Comment 1 Jakub Jelinek 2014-04-28 15:27:57 UTC
You need C++ or -fno-common.  Common variables really can't have alignment increased by the compiler.
Comment 2 Andi Kleen 2014-04-29 00:17:56 UTC
Ok fair enough.