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

* [Bug tree-optimization/60196] Incorrect compilation with -fwrapv and -ftree-vectorize
  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 ` dpb at corrigendum dot ru
  2014-03-12 16:08 ` [Bug tree-optimization/60196] [4.8 Regression] " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dpb at corrigendum dot ru @ 2014-03-12 14:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Роман Донченко <dpb at corrigendum dot ru> ---
Here's another reproducer for what looks like the same problem:

#include <stdio.h>

static const short a[8] = {1,1,1,1,1,1,1,1};
static const unsigned char b[8] = {0,0,0,0,0,0,0,0};

static int foo()
{
    int sum = 0, i;

    for (i = 0; i < 8; ++i)
        sum += a[i] * b[i];

    return sum;
}

int main()
{
    printf("%d\n", foo());
    return 0;
}

The correct result is 0, but compiling with -O1 -ftree-vectorize yields 8. I
looked at the disassembly, and it just sums the elements of a, b is not used at
all.

For this one, adding -fwrapv actually fixes it, but I don't think there are any
overflows here.
>From gcc-bugs-return-446112-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Mar 12 14:38:15 2014
Return-Path: <gcc-bugs-return-446112-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10925 invoked by alias); 12 Mar 2014 14:38:15 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 10883 invoked by uid 48); 12 Mar 2014 14:38:11 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/57189] [4.9 Regression] Vector register is spilled for vector extract pattern
Date: Wed, 12 Mar 2014 14:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: missed-optimization, ra
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: priority cc
Message-ID: <bug-57189-4-yVqVonH181@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57189-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57189-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-03/txt/msg00981.txt.bz2
Content-length: 516

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW189

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2
                 CC|                            |vmakarov at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
IMHO not worth P1 status.  Would be nice if Vlad could have a look eventually
though.


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

* [Bug tree-optimization/60196] [4.8 Regression] Incorrect compilation with -fwrapv and -ftree-vectorize
  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 ` jakub at gcc dot gnu.org
  2014-05-22  9:02 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-03-12 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-03-12
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.8.3
            Summary|Incorrect compilation with  |[4.8 Regression] Incorrect
                   |-fwrapv and                 |compilation with -fwrapv
                   |-ftree-vectorize            |and -ftree-vectorize
     Ever confirmed|0                           |1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r185437 and fixed again with r202663 (both testcases).


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

* [Bug tree-optimization/60196] [4.8 Regression] Incorrect compilation with -fwrapv and -ftree-vectorize
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-22  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.3                       |4.8.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 4.8.3 is being released, adjusting target milestone.


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

* [Bug tree-optimization/60196] [4.8 Regression] Incorrect compilation with -fwrapv and -ftree-vectorize
  2014-02-14 15:22 [Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize dpb at corrigendum dot ru
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-09-08 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Mon Sep  8 20:07:29 2014
New Revision: 215024

URL: https://gcc.gnu.org/viewcvs?rev=215024&root=gcc&view=rev
Log:
    PR tree-optimization/60196
    PR tree-optimization/63189
    Backported from mainline
    2013-09-17  Cong Hou  <congh@google.com>

    * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Fix a bug
    when checking the dot production pattern. The type of rhs operand
    of multiply is now checked correctly.

    * gcc.dg/vect/pr63189.c: New test.
    * gcc.dg/vect/pr60196-1.c: New test.
    * gcc.dg/vect/pr60196-2.c: New test.

    Backported from mainline
    2013-09-17  Cong Hou  <congh@google.com>

    * gcc.dg/vect/vect-reduc-dot-s16c.c: Add a test case with dot product 
    on two arrays with short and int types. This should not be recognized
    as a dot product pattern.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr60196-1.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr60196-2.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr63189.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-s16c.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-vect-patterns.c


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

* [Bug tree-optimization/60196] [4.8 Regression] Incorrect compilation with -fwrapv and -ftree-vectorize
  2014-02-14 15:22 [Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize dpb at corrigendum dot ru
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-09-08 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Mon Sep  8 20:15:31 2014
New Revision: 215025

URL: https://gcc.gnu.org/viewcvs?rev=215025&root=gcc&view=rev
Log:
    PR tree-optimization/60196
    PR tree-optimization/63189
    * gcc.dg/vect/pr63189.c: New test.
    * gcc.dg/vect/pr60196-1.c: New test.
    * gcc.dg/vect/pr60196-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/vect/pr60196-1.c
    trunk/gcc/testsuite/gcc.dg/vect/pr60196-2.c
    trunk/gcc/testsuite/gcc.dg/vect/pr63189.c
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/60196] [4.8 Regression] Incorrect compilation with -fwrapv and -ftree-vectorize
  2014-02-14 15:22 [Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize dpb at corrigendum dot ru
                   ` (5 preceding siblings ...)
  2014-09-08 20:18 ` jakub at gcc dot gnu.org
@ 2014-09-08 20:18 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-09-08 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.


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

* [Bug tree-optimization/60196] [4.8 Regression] Incorrect compilation with -fwrapv and -ftree-vectorize
  2014-02-14 15:22 [Bug tree-optimization/60196] New: Incorrect compilation with -fwrapv and -ftree-vectorize dpb at corrigendum dot ru
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-09-08 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Mon Sep  8 20:18:02 2014
New Revision: 215026

URL: https://gcc.gnu.org/viewcvs?rev=215026&root=gcc&view=rev
Log:
    PR tree-optimization/60196
    PR tree-optimization/63189
    * gcc.dg/vect/pr63189.c: New test.
    * gcc.dg/vect/pr60196-1.c: New test.
    * gcc.dg/vect/pr60196-2.c: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60196-1.c
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60196-2.c
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr63189.c
Modified:
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


^ 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).