Bug 20122 - Wrong code with gcc 4.0 tree-vectorizer
Summary: Wrong code with gcc 4.0 tree-vectorizer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Ira Rosen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-21 16:16 UTC by Michael Cieslinski
Modified: 2005-05-02 12:01 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-03-02 12:43:57


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Cieslinski 2005-02-21 16:16:25 UTC
This small test program generates a segfault if it is compiled with:
gcc40 -march=opteron -O2 -ftree-vectorize gccbug.cpp -o gccbug

Segfault does not occur when __attribute__((noinline)) is omitted.
It occurs with snapshot 20050213 and snapshot 20050220,
but not with snapshot 20050130


Michael Cieslinski


==========================
#include <emmintrin.h>

static struct KStructType
{union{
    short         Kernshort[8][24];
    __m128i     KernSSE[8][3];
};} KU          __attribute__(( aligned(16) ));

static void VecBug(short Kernel[8][24]) __attribute__((noinline));
static void VecBug(short Kernel[8][24])
{
    for (int k = 0; k<8; k++)
        for (int i = 0; i<24; i++)
            KU.Kernshort[k][i] = Kernel[k][i];
}

int main (int argc, char **argv)
{
    short Kernel[8][24];
    for (int k = 0; k<8; k++)
        for (int i = 0; i<24; i++)
            Kernel[k][i] = 0;

    VecBug(Kernel);

    return 0;
}
Comment 1 Andrew Pinski 2005-02-21 18:49:35 UTC
I think this is related to PR 19716.  Note the tree level looks correct to me.
Comment 2 Ira Rosen 2005-02-24 13:41:45 UTC
I found the problem that causes this. I'll send the patch next week.
Ira
Comment 3 Michael Cieslinski 2005-03-02 10:27:21 UTC
After you found the problem, may I ask you to set the status NEW and target 
milestone to 4.0.0 ?
That way this bug would show up in the list of open bugs for gcc40. 

Michael Cieslinski
Comment 4 Giovanni Bajo 2005-03-02 11:42:35 UTC
Ira, can you please remember to confirm bugs in Bugzilla when you find them?

Micheal, this bug cannot be fixed in 4.0 since it is not a regression (the 
vectorizer is new). I would argue in favor of a new rule that allows to fix 
bugs in release branches for new features which are disabled by default, but 
for now this bug won't have a 4.0 milestone.
Comment 5 Ira Rosen 2005-03-02 12:45:57 UTC
Fixed in http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01788.html. Waiting for 
review.
Comment 6 Michael Cieslinski 2005-03-03 10:44:33 UTC
I applied you patch and did a full bootstrap on x86_64.
No new regressions. 
It fixes my problem.

Michael Cieslinski
Comment 7 Michael Cieslinski 2005-05-02 11:58:41 UTC
The patch given in comment #5 seems to be included in gcc400 and in mainline.
I think this PR should be closed.

Michael Cieslinski