public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] Wrong constant folding
Date: Wed, 28 May 2014 11:10:00 -0000	[thread overview]
Message-ID: <bug-61045-4-etF0OAU99X@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61045-4@http.gcc.gnu.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.


  parent reply	other threads:[~2014-05-28 11:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-03 15:41 [Bug tree-optimization/61045] New: " ishiura-compiler at ml dot kwansei.ac.jp
2014-05-03 15:57 ` [Bug tree-optimization/61045] " mpolacek at gcc dot gnu.org
2014-05-03 15:59 ` [Bug middle-end/61045] [4.7/4.8/4.9/4.10 Regression] " mpolacek at gcc dot gnu.org
2014-05-03 16:00 ` mikpelinux at gmail dot com
2014-05-03 17:02 ` mpolacek at gcc dot gnu.org
2014-05-03 19:31 ` mikpelinux at gmail dot com
2014-05-05  9:11 ` rguenth at gcc dot gnu.org
2014-05-28 11:10 ` rguenth at gcc dot gnu.org [this message]
2014-05-28 12:44 ` rguenth at gcc dot gnu.org
2014-05-28 12:47 ` rguenth at gcc dot gnu.org
2014-06-12 13:44 ` [Bug middle-end/61045] [4.7/4.8 " rguenth at gcc dot gnu.org
2014-09-09 13:18 ` [Bug middle-end/61045] [4.8 " rguenth at gcc dot gnu.org
2014-09-09 13:19 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61045-4-etF0OAU99X@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).