This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 28 May 2014 11:10:22 +0000
- Subject: [Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding
- Auto-submitted: auto-generated
- References: <bug-61045-4 at http dot gcc dot gnu dot org/bugzilla/>
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.