public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/63380] New: Wrong constant folding
@ 2014-09-26  9:45 ishiura-compiler at ml dot kwansei.ac.jp
  2014-10-02 15:01 ` [Bug tree-optimization/63380] [5 Regression] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ishiura-compiler at ml dot kwansei.ac.jp @ 2014-09-26  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63380
           Summary: Wrong constant folding
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 5.0.0 for x86_64 miscompiles the following code.

   $ cat test.c

    int a = 0, b = 1, c = 0, d = 1, e, f, g, h;
    int
    main ()
    {
      e = 1 >> d;
      f = ((31 / (1 > e)) || c) / 2;
      g = b || a;
      h = 31 / g;
      if (!h)
        __builtin_abort();
      return 0;
    }

   $ x86_64-unknown-linux-gnu-gcc-5.0.0 test.c -O2
   $ ./a.out
   Floating point exception (core dumped)

   $ x86_64-unknown-linux-gnu-gcc-5.0.0 -v
    Using built-in specs.
    COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-5.0.0
    COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-
    5.0.0/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
    Target: x86_64-unknown-linux-gnu
    Configured with: /home/orange3/gcc-master/configure --
    prefix=/usr/local/x86_64-tools/gcc-5.0.0/ --with-gmp=/usr/local/gmp-
    5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/ --with-mpc=/usr/local/mpc-
    1.0.1/ --disable-multilib --disable-nls --enable-languages=c
    Thread model: posix
    gcc version 5.0.0 20140922 (experimental) (GCC)


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

* [Bug tree-optimization/63380] [5 Regression] Wrong constant folding
  2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
@ 2014-10-02 15:01 ` mpolacek at gcc dot gnu.org
  2014-10-06 12:05 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-10-02 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-10-02
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |5.0
            Summary|Wrong constant folding      |[5 Regression] Wrong
                   |                            |constant folding
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Works with -fno-tree-vrp.  Seems to have started with r211904.


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

* [Bug tree-optimization/63380] [5 Regression] Wrong constant folding
  2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
  2014-10-02 15:01 ` [Bug tree-optimization/63380] [5 Regression] " mpolacek at gcc dot gnu.org
@ 2014-10-06 12:05 ` rguenth at gcc dot gnu.org
  2014-10-08 14:58 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-06 12:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.


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

* [Bug tree-optimization/63380] [5 Regression] Wrong constant folding
  2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
  2014-10-02 15:01 ` [Bug tree-optimization/63380] [5 Regression] " mpolacek at gcc dot gnu.org
  2014-10-06 12:05 ` rguenth at gcc dot gnu.org
@ 2014-10-08 14:58 ` rguenth at gcc dot gnu.org
  2014-10-09  8:18 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-08 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm.  We end up with

main ()
{
  int d.0_4;
  int e.1_5;
  int _7;
  int b.7_11;
  int a.8_12;

  <bb 2>:
  d.0_4 = d;
  e.1_5 = 1 >> d.0_4;
  e = e.1_5;
  _7 = 31 / 0;

in the end.  Which is caused by tail-merging (part of PRE) optimizing

  <bb 2>:
  d.0_4 = d;
  e.1_5 = 1 >> d.0_4;
  e = e.1_5;
  if (e.1_5 <= 0)
    goto <bb 10>;
  else
    goto <bb 3>;

  <bb 10>:
  goto <bb 4>;

  <bb 3>:
  _7 = 31 / 0;

  <bb 4>:

by removing bb 3 as having no side-effect appearantly (_7 is unused).  It
produces

  <bb 2>:
  d.0_4 = d;
  e.1_5 = 1 >> d.0_4;
  e = e.1_5;

  <bb 3>:
  _7 = 31 / 0;

  <bb 4>:

not sure how it ends up doing that (I suppose it has code to merge an
if diamond).


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

* [Bug tree-optimization/63380] [5 Regression] Wrong constant folding
  2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
                   ` (2 preceding siblings ...)
  2014-10-08 14:58 ` rguenth at gcc dot gnu.org
@ 2014-10-09  8:18 ` rguenth at gcc dot gnu.org
  2014-10-09 12:45 ` rguenth at gcc dot gnu.org
  2014-10-10 11:06 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-09  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 63381 has been marked as a duplicate of this bug. ***


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

* [Bug tree-optimization/63380] [5 Regression] Wrong constant folding
  2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
                   ` (3 preceding siblings ...)
  2014-10-09  8:18 ` rguenth at gcc dot gnu.org
@ 2014-10-09 12:45 ` rguenth at gcc dot gnu.org
  2014-10-10 11:06 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-09 12:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Thu Oct  9 12:45:07 2014
New Revision: 216038

URL: https://gcc.gnu.org/viewcvs?rev=216038&root=gcc&view=rev
Log:
2014-10-09  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/63380
    * tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that
    may trap.

    * gcc.dg/torture/pr63380-1.c: New testcase.
    * gcc.dg/torture/pr63380-2.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr63380-1.c
    trunk/gcc/testsuite/gcc.dg/torture/pr63380-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-tail-merge.c


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

* [Bug tree-optimization/63380] [5 Regression] Wrong constant folding
  2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
                   ` (4 preceding siblings ...)
  2014-10-09 12:45 ` rguenth at gcc dot gnu.org
@ 2014-10-10 11:06 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-10 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Fri Oct 10 11:05:39 2014
New Revision: 216066

URL: https://gcc.gnu.org/viewcvs?rev=216066&root=gcc&view=rev
Log:
2014-10-10  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/63380
    * tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that
    may trap.

    * gcc.dg/torture/pr63380-1.c: New testcase.
    * gcc.dg/torture/pr63380-2.c: Likewise.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr63380-1.c
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr63380-2.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-ssa-tail-merge.c


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

end of thread, other threads:[~2014-10-10 11:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-26  9:45 [Bug tree-optimization/63380] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
2014-10-02 15:01 ` [Bug tree-optimization/63380] [5 Regression] " mpolacek at gcc dot gnu.org
2014-10-06 12:05 ` rguenth at gcc dot gnu.org
2014-10-08 14:58 ` rguenth at gcc dot gnu.org
2014-10-09  8:18 ` rguenth at gcc dot gnu.org
2014-10-09 12:45 ` rguenth at gcc dot gnu.org
2014-10-10 11:06 ` rguenth 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).