This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60196

            Bug ID: 60196
           Summary: Incorrect compilation with -fwrapv and
                    -ftree-vectorize
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dpb at corrigendum dot ru

Created attachment 32135
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32135&action=edit
Preprocessed source for the reproducer

This program should print 36 (preprocessed source attached):

#include <stdio.h>

static int foo(const short * a, int len)
{
    int x;

    int x1 = 0;

    for( x = 0; x < len; x++ )
        x1 += x * a[x];

    return x1;
}

int main()
{
    short stuff[9] = {1,1,1,1,1,1,1,1,1};

    printf("%d\n", foo(stuff, 9));
    return 0;
}

However, if compiled with -O1 -fwrapv -ftree-vectorize, it prints 16 instead.
Omitting any of those flags gives the correct result.

I can reproduce this on 4.8.2 and 4.8 branch head. It doesn't reproduce on
trunk, though. (All three built from vanilla source.) Target is
x86_64-unknown-linux-gnu.

I also tested it on a bunch of Ubuntu's prebuilt GCC versions. It reproduces on
4.6.4, 4.7.3, 4.8.1, but not on 4.4.7.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]