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/49218] Incorrect optimization of a 'for' loop creates an infinite loop
Date: Mon, 30 May 2011 09:14:00 -0000	[thread overview]
Message-ID: <bug-49218-4-b0xvLzd5jY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49218-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-30 09:13:17 UTC ---
I'm going to test

@@ -3423,11 +3423,14 @@ adjust_range_with_scev (value_range_t *v
                                            loop->nb_iterations_upper_bound,
                                            double_int_one),
                                        unsigned_p, &overflow);
-      tem = double_int_to_tree (TREE_TYPE (init), dtmp);
       /* If the multiplication overflowed we can't do a meaningful
-        adjustment.  */
-      if (!overflow && double_int_equal_p (dtmp, tree_to_double_int (tem)))
+        adjustment.  Likewise if the unsigned result doesn't fit in the type
+        of the induction variable.  */
+      if (!overflow
+         && double_int_fits_to_tree_p (TREE_TYPE (init), dtmp)
+         && (unsigned_p || dtmp.high > 0))
        {
+         tem = double_int_to_tree (TREE_TYPE (init), dtmp);
          extract_range_from_binary_expr (&maxvr, PLUS_EXPR,
                                          TREE_TYPE (init), init, tem);
          /* Likewise if the addition did.  */


  parent reply	other threads:[~2011-05-30  9:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-29  2:14 [Bug tree-optimization/49218] New: " personal@e-maxx.ru
2011-05-29 10:23 ` [Bug tree-optimization/49218] " rguenth at gcc dot gnu.org
2011-05-29 11:47 ` mikpe at it dot uu.se
2011-05-29 16:38 ` rguenth at gcc dot gnu.org
2011-05-29 17:20 ` rguenth at gcc dot gnu.org
2011-05-29 17:43 ` rguenth at gcc dot gnu.org
2011-05-29 17:50 ` rguenth at gcc dot gnu.org
2011-05-30  8:36 ` jakub at gcc dot gnu.org
2011-05-30  9:03 ` mikpe at it dot uu.se
2011-05-30  9:14 ` rguenth at gcc dot gnu.org [this message]
2011-05-30 11:18 ` rguenth at gcc dot gnu.org
2011-05-30 11:19 ` rguenth at gcc dot gnu.org
2011-05-30 11:27 ` 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-49218-4-b0xvLzd5jY@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).