public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
@ 2013-06-20  6:14 ` jakub at gcc dot gnu.org
  2013-06-20  9:06 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-06-20  6:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.7.4
            Summary|Wrong constant folding      |[4.7/4.8/4.9 Regression]
                   |                            |Wrong constant folding

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Most likely broken by the r117969 changes.


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

* [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
  2013-06-20  6:14 ` [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding jakub at gcc dot gnu.org
@ 2013-06-20  9:06 ` rguenth at gcc dot gnu.org
  2013-06-24 11:55 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-06-20  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-06-20
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

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


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

* [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
  2013-06-20  6:14 ` [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding jakub at gcc dot gnu.org
  2013-06-20  9:06 ` rguenth at gcc dot gnu.org
@ 2013-06-24 11:55 ` rguenth at gcc dot gnu.org
  2013-09-03 10:00 ` [Bug tree-optimization/57656] [4.7/4.8 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-06-24 11:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 30352
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30352&action=edit
patch

Fails at -O0 -fstrict-overflow as we fold

  int t = 1 - (a - b) / c;

into

  int t = (b - a) / c + 1;

The change in r117969 exposed a bug in negate_expr_p, namely that
we cannot negate (a - b) / c as (b - a) / c because that associates
the negate with the division which exposes possible undefined overflow
in -(a - b) that is not there in the original expression for c != +-1.

This is a bit a problem with the negate_expr_p specification - the API
doesn't specify whether we are removing an existing negate or whether
we are adding one.  This case removes one from the division and adds
it to the subtraction.  -(a - b) -> (b - a) is ok, but (a - b) -> -(b - a)
is not - the API doesn't really distinguish these two cases but in the
MINUS_EXPR case clearly implements -(a - b) -> (b - a).

Testing the attached.


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

* [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-09-03 10:00 ` [Bug tree-optimization/57656] [4.7/4.8 " rguenth at gcc dot gnu.org
@ 2013-09-03 10:00 ` rguenth at gcc dot gnu.org
  2013-09-09  9:49 ` [Bug tree-optimization/57656] [4.7/4.8 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-09-03 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Sep  3 10:00:06 2013
New Revision: 202204

URL: http://gcc.gnu.org/viewcvs?rev=202204&root=gcc&view=rev
Log:
2013-09-03  Richard Biener  <rguenther@suse.de>

    PR middle-end/57656
    * fold-const.c (negate_expr_p): Fix division case.
    (negate_expr): Likewise.

    * gcc.dg/torture/pr57656.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr57656.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/57656] [4.7/4.8 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2013-06-24 11:55 ` rguenth at gcc dot gnu.org
@ 2013-09-03 10:00 ` rguenth at gcc dot gnu.org
  2013-09-03 10:00 ` [Bug tree-optimization/57656] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-09-03 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.9.0
            Summary|[4.7/4.8/4.9 Regression]    |[4.7/4.8 Regression] Wrong
                   |Wrong constant folding      |constant folding

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.


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

* [Bug tree-optimization/57656] [4.7/4.8 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2013-09-03 10:00 ` [Bug tree-optimization/57656] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
@ 2013-09-09  9:49 ` rguenth at gcc dot gnu.org
  2014-03-18  8:47 ` [Bug tree-optimization/57656] [4.7 " rguenth at gcc dot gnu.org
  2014-03-18  8:47 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-09-09  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Mon Sep  9 09:49:54 2013
New Revision: 202387

URL: http://gcc.gnu.org/viewcvs?rev=202387&root=gcc&view=rev
Log:
2013-09-09  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2013-09-03  Richard Biener  <rguenther@suse.de>

    PR middle-end/57656
    * fold-const.c (negate_expr_p): Fix division case.
    (negate_expr): Likewise.

    * gcc.dg/torture/pr57656.c: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr57656.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/fold-const.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/57656] [4.7 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2013-09-09  9:49 ` [Bug tree-optimization/57656] [4.7/4.8 " rguenth at gcc dot gnu.org
@ 2014-03-18  8:47 ` rguenth at gcc dot gnu.org
  2014-03-18  8:47 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-03-18  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Mar 18 08:46:21 2014
New Revision: 208632

URL: http://gcc.gnu.org/viewcvs?rev=208632&root=gcc&view=rev
Log:
2014-03-18  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2013-08-27  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/57521
    * tree-if-conv.c (if_convertible_bb_p): Verify that at least
    one edge is non-critical.
    (find_phi_replacement_condition): Make sure to use a non-critical
    edge.  Cleanup and remove old bug workarounds.
    (bb_postdominates_preds): Remove.
    (if_convertible_loop_p_1): Do not compute post-dominators.
    (combine_blocks): Do not free post-dominators.
    (main_tree_if_conversion): Likewise.

    * gcc.dg/torture/pr57521.c: New testcase.

    2013-09-03  Richard Biener  <rguenther@suse.de>

    PR middle-end/57656
    * fold-const.c (negate_expr_p): Fix division case.
    (negate_expr): Likewise.

    * gcc.dg/torture/pr57656.c: New testcase.

    2013-11-19  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/57517
    * tree-predcom.c (combinable_refs_p): Verify the combination
    is always executed when the refs are.

    * gfortran.fortran-torture/compile/pr57517.f90: New testcase.
    * gcc.dg/torture/pr57517.c: Likewise.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr57517.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr57521.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr57656.c
   
branches/gcc-4_7-branch/gcc/testsuite/gfortran.fortran-torture/compile/pr57517.f90
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/fold-const.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-if-conv.c
    branches/gcc-4_7-branch/gcc/tree-predcom.c


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

* [Bug tree-optimization/57656] [4.7 Regression] Wrong constant folding
       [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2014-03-18  8:47 ` [Bug tree-optimization/57656] [4.7 " rguenth at gcc dot gnu.org
@ 2014-03-18  8:47 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-03-18  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-03-18  8:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-57656-4@http.gcc.gnu.org/bugzilla/>
2013-06-20  6:14 ` [Bug tree-optimization/57656] [4.7/4.8/4.9 Regression] Wrong constant folding jakub at gcc dot gnu.org
2013-06-20  9:06 ` rguenth at gcc dot gnu.org
2013-06-24 11:55 ` rguenth at gcc dot gnu.org
2013-09-03 10:00 ` [Bug tree-optimization/57656] [4.7/4.8 " rguenth at gcc dot gnu.org
2013-09-03 10:00 ` [Bug tree-optimization/57656] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
2013-09-09  9:49 ` [Bug tree-optimization/57656] [4.7/4.8 " rguenth at gcc dot gnu.org
2014-03-18  8:47 ` [Bug tree-optimization/57656] [4.7 " rguenth at gcc dot gnu.org
2014-03-18  8:47 ` 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).