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/58143] [4.8/4.9 regression] wrong code at -O3
Date: Tue, 15 Oct 2013 11:03:00 -0000	[thread overview]
Message-ID: <bug-58143-4-LVlZ50KGoi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58143-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
For the testcase in PR58731,

int a, b, c, d, e;

int
main ()
{
  for (b = 4; b > -30; b--)
    for (; c;)
      for (;;)
    {
      e = a > 2147483647 - b;
      if (d)
        break;
    }
  return 0;
}

after rewriting 2147483647 - b to unsigned arithmetic, IVOPTs re-writes it
to signed arithmetic again, making VRP remove the loop exit test.  Bah.

--- pr58143-3.c.118t.slp        2013-10-15 12:56:07.040864240 +0200
+++ pr58143-3.c.120t.ivopts     2013-10-15 12:56:07.041864251 +0200
@@ -5,18 +5,14 @@
 {
   int b_lsm.10;
   int e_lsm.9;
-  int pretmp_3;
-  unsigned int ivtmp_6;
-  unsigned int _12;
+  int _13;
   int b.5_14;
-  unsigned int _15;
   int pretmp_16;
   int pretmp_17;
   int b.0_20;
   _Bool pretmp_22;
   int pretmp_23;
   int pretmp_24;
-  unsigned int ivtmp_27;

   <bb 2>:
   b = 4;
@@ -45,11 +41,8 @@
   <bb 8>:
   # b.0_20 = PHI <b.5_14(11), 4(2)>
   # e_lsm.9_19 = PHI <e_lsm.9_30(11), e_lsm.9_21(2)>
-  # ivtmp_6 = PHI <ivtmp_27(11), 34(2)>
-  _15 = (unsigned int) b.0_20;
-  _12 = 2147483647 - _15;
-  pretmp_3 = (int) _12;
-  pretmp_22 = pretmp_3 < pretmp_16;
+  _13 = 2147483647 - b.0_20;
+  pretmp_22 = _13 < pretmp_16;
   pretmp_23 = (int) pretmp_22;

   <bb 9>:
@@ -62,8 +55,7 @@
   <bb 10>:
   # e_lsm.9_30 = PHI <e_lsm.9_25(9)>
   b.5_14 = b.0_20 + -1;
-  ivtmp_27 = ivtmp_6 - 1;
-  if (ivtmp_27 != 0)
+  if (b.5_14 != -30)
     goto <bb 11>;
   else
     goto <bb 12>;

possibly via some bug in SCEV and/or fold.  That said,

int a, b, c, d, e;

int
main ()
{
  for (b = 4; b > -30; b--)
    {
    e = a > (int)((unsigned int) __INT_MAX__ - (unsigned int) b);
    for (; c;)
      for (;;)
        {
          if (d)
            break;
        }
    }
  return 0;
}

fails the same way, even with -fno-tree-loop-im (but still needs -O3
for some reason).


  parent reply	other threads:[~2013-10-15 11:03 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13  0:05 [Bug middle-end/58143] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2013-08-13  0:08 ` [Bug middle-end/58143] " pinskia at gcc dot gnu.org
2013-08-13  0:24 ` su at cs dot ucdavis.edu
2013-08-14 21:11 ` mikpe at it dot uu.se
2013-08-20  0:21 ` bernd.edlinger at hotmail dot de
2013-08-20  0:59 ` bernd.edlinger at hotmail dot de
2013-08-20 22:25 ` bernd.edlinger at hotmail dot de
2013-08-21  8:53 ` bernd.edlinger at hotmail dot de
2013-08-21 17:41 ` [Bug tree-optimization/58143] [4.8/4.9 regression] wrong code at -O3 ebotcazou at gcc dot gnu.org
2013-08-21 18:02 ` jakub at gcc dot gnu.org
2013-08-21 21:50 ` bernd.edlinger at hotmail dot de
2013-08-23  9:15 ` bernd.edlinger at hotmail dot de
2013-08-23  9:16 ` jakub at gcc dot gnu.org
2013-08-23 12:08 ` bernd.edlinger at hotmail dot de
2013-08-23 12:59 ` jakub at gcc dot gnu.org
2013-08-25 22:08 ` bernd.edlinger at hotmail dot de
2013-08-28 21:30 ` bernd.edlinger at hotmail dot de
2013-10-15  8:15 ` rguenth at gcc dot gnu.org
2013-10-15  8:17 ` rguenth at gcc dot gnu.org
2013-10-15  8:39 ` bernd.edlinger at hotmail dot de
2013-10-15  9:05 ` rguenth at gcc dot gnu.org
2013-10-15  9:41 ` rguenth at gcc dot gnu.org
2013-10-15 11:03 ` rguenth at gcc dot gnu.org [this message]
2013-10-15 11:45 ` bernd.edlinger at hotmail dot de
2013-10-15 11:54 ` rguenth at gcc dot gnu.org
2013-10-15 11:54 ` rguenther at suse dot de
2013-10-15 13:21 ` bernd.edlinger at hotmail dot de
2013-10-15 13:27 ` rguenther at suse dot de
2013-10-15 13:36 ` mikpelinux at gmail dot com
2013-10-15 13:38 ` bernd.edlinger at hotmail dot de
2013-10-15 13:40 ` rguenther at suse dot de
2013-10-16  9:51 ` jakub at gcc dot gnu.org
2013-10-17  9:59 ` rguenth at gcc dot gnu.org
2013-10-17 10:08 ` [Bug tree-optimization/58143] [4.8 " rguenth at gcc dot gnu.org
2013-11-18 15:14 ` rguenth at gcc dot gnu.org
2013-11-18 15:15 ` 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-58143-4-LVlZ50KGoi@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).