This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]