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 tree-optimization/53501] [4.5/4.6/4.7/4.8 Regression] scev introduces signed overflow
Date: Wed, 30 May 2012 10:55:00 -0000	[thread overview]
Message-ID: <bug-53501-4-Ec6uWX5UY2@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53501-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-05-30 10:34:50 UTC ---
It's my very best friend extract_muldiv that transforms
(int)((unsigned int) n.0_26 + 4294967295) * 2
to (int)(((unsigned int) n.0_26 + 2147483647) * 2) 

It is the folding of (int) (((unsigned int) n.0_26 + 2147483647) * 2) + 2
which is wrong and done by fold_plusminus_mult_expr.  Patch:

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c    (revision 188004)
+++ gcc/fold-const.c    (working copy)
@@ -10045,12 +10045,12 @@ fold_binary_loc (location_t loc,
       /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the
         same or one.  Make sure type is not saturating.
         fold_plusminus_mult_expr will re-associate.  */
-      if ((TREE_CODE (arg0) == MULT_EXPR
-          || TREE_CODE (arg1) == MULT_EXPR)
+      if ((TREE_CODE (op0) == MULT_EXPR
+          || TREE_CODE (op1) == MULT_EXPR)
          && !TYPE_SATURATING (type)
          && (!FLOAT_TYPE_P (type) || flag_associative_math))
         {
-         tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1);
+         tree tem = fold_plusminus_mult_expr (loc, code, type, op0, op1);
          if (tem)
            return tem;
        }

that will leave the expression unsimplified.


  parent reply	other threads:[~2012-05-30 10:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27 23:11 [Bug tree-optimization/53501] New: incorrect loop optimization with -O2 misof at gcc dot ksp.sk
2012-05-29 16:15 ` [Bug tree-optimization/53501] [4.5/4.6/4.7/4.8 Regression] scev introduces signed overflow amonakov at gcc dot gnu.org
2012-05-30  9:58 ` rguenth at gcc dot gnu.org
2012-05-30 10:55 ` rguenth at gcc dot gnu.org [this message]
2012-05-30 12:31 ` rguenth at gcc dot gnu.org
2012-05-30 12:34 ` rguenth at gcc dot gnu.org
2012-05-30 12:34 ` [Bug tree-optimization/53501] [4.5/4.6 " rguenth at gcc dot gnu.org
2012-06-01 17:01 ` ebotcazou at gcc dot gnu.org
2012-06-01 17:03 ` ebotcazou at gcc dot gnu.org
2012-06-20 13:23 ` rguenth at gcc dot gnu.org
2012-07-02 10:57 ` rguenth at gcc dot gnu.org
2013-04-12 16:25 ` [Bug tree-optimization/53501] [4.6 " jakub 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-53501-4-Ec6uWX5UY2@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).