public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix typo, fixing PR87465
@ 2018-10-01  9:36 Richard Biener
  2018-10-03 15:56 ` Christophe Lyon
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2018-10-01  9:36 UTC (permalink / raw)
  To: gcc-patches


The following typo-fix happens to fix a --param max-peel-branches limit
caused missed peeling.  The typo is present everywhere, the missed
peeling is a regression from GCC 7.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

I'm not really considering to backport this anywhere.  Note the
testcase isn't fully optimized on the tree level because
DOM doesn't figure out the trivial CSE after SLP vectorizes the
array init (we have PRs for that issue).

Richard.

2018-10-01  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/87465
	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Fix typo
	causing branch miscounts.

	* gcc.dg/tree-ssa/cunroll-15.c: New testcase.

Index: gcc/tree-ssa-loop-ivcanon.c
===================================================================
--- gcc/tree-ssa-loop-ivcanon.c	(revision 264734)
+++ gcc/tree-ssa-loop-ivcanon.c	(working copy)
@@ -368,8 +368,8 @@ tree_estimate_loop_size (struct loop *lo
 	    size->non_call_stmts_on_hot_path++;
 	  if (((gimple_code (stmt) == GIMPLE_COND
 	        && (!constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
-		    || constant_after_peeling (gimple_cond_rhs (stmt), stmt,
-					       loop)))
+		    || !constant_after_peeling (gimple_cond_rhs (stmt), stmt,
+						loop)))
 	       || (gimple_code (stmt) == GIMPLE_SWITCH
 		   && !constant_after_peeling (gimple_switch_index (
 						 as_a <gswitch *> (stmt)),
Index: gcc/testsuite/gcc.dg/tree-ssa/cunroll-15.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/cunroll-15.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/tree-ssa/cunroll-15.c	(working copy)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-cunroll-optimized" } */
+
+int Test(void)
+{
+  int c = 0;
+  const int in[4] = {4,3,4,4};
+  for (unsigned i = 0; i < 4; i++) {
+      for (unsigned j = 0; j < i; j++) {
+	  if (in[i] == in[j])
+	    break;
+	  else 
+	    ++c;
+      }
+  }
+  return c;
+}
+
+/* { dg-final { scan-tree-dump-times "optimized:\[^\n\r\]*completely unrolled" 2 "cunroll" } } */
+/* Only RTL figures out some CSE at the moment.  */
+/* { dg-final { scan-tree-dump "return 1;" "optimized" { xfail *-*-* } } } */

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-04 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  9:36 [PATCH] Fix typo, fixing PR87465 Richard Biener
2018-10-03 15:56 ` Christophe Lyon
2018-10-04  9:23   ` Richard Biener
2018-10-04 14:12     ` Jeff Law

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).