public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize
@ 2014-02-14 15:22 dpb at corrigendum dot ru
  2014-03-12 14:33 ` [Bug tree-optimization/60196] " dpb at corrigendum dot ru
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dpb at corrigendum dot ru @ 2014-02-14 15:22 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-09-08 20:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 15:22 [Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize dpb at corrigendum dot ru
2014-03-12 14:33 ` [Bug tree-optimization/60196] " dpb at corrigendum dot ru
2014-03-12 16:08 ` [Bug tree-optimization/60196] [4.8 Regression] " jakub at gcc dot gnu.org
2014-05-22  9:02 ` rguenth at gcc dot gnu.org
2014-09-08 20:08 ` jakub at gcc dot gnu.org
2014-09-08 20:16 ` jakub at gcc dot gnu.org
2014-09-08 20:18 ` jakub at gcc dot gnu.org
2014-09-08 20:18 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).