[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-28 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

--- Comment #6 from Richard Biener rguenth at gcc dot gnu.org ---
  /* Put the constant on the side where it doesn't overflow and is
 of lower absolute value than before.  */
  cst = int_const_binop (TREE_CODE (arg0) == TREE_CODE (arg1)
 ? MINUS_EXPR : PLUS_EXPR,
 const2, const1);
  if (!TREE_OVERFLOW (cst)
   tree_int_cst_compare (const2, cst) == tree_int_cst_sgn (const2))

const2 is -1 here and cst is 1.  So that means just checking for
lower absolute value is wrong.  A sign-change is obviously not ok either.


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-28 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

--- Comment #7 from Richard Biener rguenth at gcc dot gnu.org ---
Author: rguenth
Date: Wed May 28 12:44:11 2014
New Revision: 211018

URL: http://gcc.gnu.org/viewcvs?rev=211018root=gccview=rev
Log:
2014-05-28  Richard Biener  rguent...@suse.de

PR middle-end/61045
* fold-const.c (fold_comparison): When folding
X +- C1 CMP Y +- C2 to X CMP Y +- C2 +- C1 also ensure
the sign of the remaining constant operand stays the same.

* gcc.dg/pr61045.c: New testcase.

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


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-28 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

--- Comment #8 from Richard Biener rguenth at gcc dot gnu.org ---
Author: rguenth
Date: Wed May 28 12:46:39 2014
New Revision: 211019

URL: http://gcc.gnu.org/viewcvs?rev=211019root=gccview=rev
Log:
2014-05-28  Richard Biener  rguent...@suse.de

Backport from mainline
2014-05-28  Richard Biener  rguent...@suse.de

PR middle-end/61045
* fold-const.c (fold_comparison): When folding
X +- C1 CMP Y +- C2 to X CMP Y +- C2 +- C1 also ensure
the sign of the remaining constant operand stays the same.

* gcc.dg/pr61045.c: New testcase.

2014-05-05  Richard Biener  rguent...@suse.de

PR middle-end/61010
* fold-const.c (fold_binary_loc): Consistently avoid
canonicalizing X  CST away from a CST that is the mask
of a mode.

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

2014-04-28  Richard Biener  rguent...@suse.de

PR tree-optimization/60979
* graphite-scop-detection.c (scopdet_basic_block_info): Reject
SCOPs that end in a block with a successor with abnormal
predecessors.

* gcc.dg/graphite/pr60979.c: New testcase.

Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr60979.c
branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61045.c
branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr61010.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/fold-const.c
branches/gcc-4_9-branch/gcc/graphite-scop-detection.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-05 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #5 from Richard Biener rguenth at gcc dot gnu.org ---
Mine then.


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-03 Thread mpolacek at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

  Component|tree-optimization   |middle-end
   Target Milestone|--- |4.7.4
Summary|Wrong constant folding  |[4.7/4.8/4.9/4.10
   ||Regression] Wrong constant
   ||folding


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-03 Thread mikpelinux at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

Mikael Pettersson mikpelinux at gmail dot com changed:

   What|Removed |Added

 CC||mikpelinux at gmail dot com

--- Comment #2 from Mikael Pettersson mikpelinux at gmail dot com ---
Fails also with gcc 4.3.6, works with gcc 4.2.4 and 4.1.2.


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-03 Thread mpolacek at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

--- Comment #3 from Marek Polacek mpolacek at gcc dot gnu.org ---
I believe this started with addition of this folding in r117931, but didn't
verify it.


[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding

2014-05-03 Thread mikpelinux at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61045

--- Comment #4 from Mikael Pettersson mikpelinux at gmail dot com ---
According to my bisection it did start with r117931.