public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: PR61583, stage2 and stage3 compare failure due to value range loss
Date: Mon, 23 Jun 2014 15:13:00 -0000	[thread overview]
Message-ID: <20140623151239.GQ3462@bubble.grove.modra.org> (raw)

This fixes a bootstrap compare failure on current mainline and 4.9
branch configured with --disable-checking, caused by losing value
range info when outputting debug info.  Lack of value range info leads
to loop bounds not being calculated, which in turn means a "j < n"
test is not converted to "j != n".  Details in the PR.

Bootstrapped and regression tested powerpc64-linux, and committed
with Jakub's approval.

gcc/
	PR bootstrap/61583
	* tree-vrp.c (remove_range_assertions): Do not set is_unreachable
	to zero on debug statements.
gcc/testsuite/
	* gcc.dg/pr61583.c: New.

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 211886)
+++ gcc/tree-vrp.c	(working copy)
@@ -6523,8 +6523,9 @@ remove_range_assertions (void)
 	  }
 	else
 	  {
+	    if (!is_gimple_debug (gsi_stmt (si)))
+	      is_unreachable = 0;
 	    gsi_next (&si);
-	    is_unreachable = 0;
 	  }
       }
 }
Index: gcc/testsuite/gcc.dg/pr61583.c
===================================================================
--- gcc/testsuite/gcc.dg/pr61583.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr61583.c	(revision 0)
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+void
+f1 (int n, int b)
+{
+  extern void f2 (int);
+  int j;
+
+  if (b)
+    n = 1;
+
+  if (n < 1)
+    __builtin_unreachable ();
+
+  for (j = 0; j < n; j++)
+    f2 (j);
+}

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2014-06-23 15:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20140623151239.GQ3462@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=gcc-patches@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).