public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR89618
@ 2019-03-07 12:06 Richard Biener
  2019-03-07 12:47 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2019-03-07 12:06 UTC (permalink / raw)
  To: gcc-patches


This fixes a missed vectorization because loop_version (and in the end
copy_loop_info) didn't copy IVDEP info (safelen) during if-conversion
versioning.

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

Even though this isn't a regression I'd like to fix this for GCC 9,
it may appear as regression to the time we didn't do versioning in
if-conversion for vectorization (but the testcase relies on AVX512
support which is newer).

Richard.

2019-04-07  Richard Biener  <rguenther@suse.de>

	PR middle-end/89618
	* cfgloopmanip.c (copy_loop_info): Copy forgotten fields.
	* tree-inline.c (copy_loops): Simplify.

	* gcc.target/i386/pr89618.c: New testcase.

Index: gcc/cfgloopmanip.c
===================================================================
--- gcc/cfgloopmanip.c	(revision 269415)
+++ gcc/cfgloopmanip.c	(working copy)
@@ -1015,10 +1015,15 @@ copy_loop_info (struct loop *loop, struc
   target->any_estimate = loop->any_estimate;
   target->nb_iterations_estimate = loop->nb_iterations_estimate;
   target->estimate_state = loop->estimate_state;
+  target->safelen = loop->safelen;
   target->constraints = loop->constraints;
+  target->can_be_parallel = loop->can_be_parallel;
   target->warned_aggressive_loop_optimizations
     |= loop->warned_aggressive_loop_optimizations;
+  target->dont_vectorize = loop->dont_vectorize;
+  target->force_vectorize = loop->force_vectorize;
   target->in_oacc_kernels_region = loop->in_oacc_kernels_region;
+  target->unroll = loop->unroll;
 }
 
 /* Copies copy of LOOP as subloop of TARGET loop, placing newly
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 269415)
+++ gcc/tree-inline.c	(working copy)
@@ -2666,23 +2666,15 @@ copy_loops (copy_body_data *id,
 
 	  /* Copy loop meta-data.  */
 	  copy_loop_info (src_loop, dest_loop);
+	  if (dest_loop->unroll)
+	    cfun->has_unroll = true;
+	  if (dest_loop->force_vectorize)
+	    cfun->has_force_vectorize_loops = true;
 
 	  /* Finally place it into the loop array and the loop tree.  */
 	  place_new_loop (cfun, dest_loop);
 	  flow_loop_tree_node_add (dest_parent, dest_loop);
 
-	  dest_loop->safelen = src_loop->safelen;
-	  if (src_loop->unroll)
-	    {
-	      dest_loop->unroll = src_loop->unroll;
-	      cfun->has_unroll = true;
-	    }
-	  dest_loop->dont_vectorize = src_loop->dont_vectorize;
-	  if (src_loop->force_vectorize)
-	    {
-	      dest_loop->force_vectorize = true;
-	      cfun->has_force_vectorize_loops = true;
-	    }
 	  if (src_loop->simduid)
 	    {
 	      dest_loop->simduid = remap_decl (src_loop->simduid, id);
Index: gcc/testsuite/gcc.target/i386/pr89618.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr89618.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr89618.c	(working copy)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -mavx512f -fdump-tree-vect-details" } */
+
+void foo (int n, int *off, double *a)
+{
+  const int m = 32;
+
+  for (int j = 0; j < n/m; ++j)
+    {
+      int const start = j*m;
+      int const end = (j+1)*m;
+
+#pragma GCC ivdep
+      for (int i = start; i < end; ++i)
+	{
+	  a[off[i]] = a[i] < 0 ? a[i] : 0;
+	}
+    }
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */

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

* Re: [PATCH] Fix PR89618
  2019-03-07 12:06 [PATCH] Fix PR89618 Richard Biener
@ 2019-03-07 12:47 ` Jakub Jelinek
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2019-03-07 12:47 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Thu, Mar 07, 2019 at 01:03:43PM +0100, Richard Biener wrote:
> 
> This fixes a missed vectorization because loop_version (and in the end
> copy_loop_info) didn't copy IVDEP info (safelen) during if-conversion
> versioning.
> 
> Bootstrap & regtest running on x86_64-unknown-linux-gnu.
> 
> Even though this isn't a regression I'd like to fix this for GCC 9,
> it may appear as regression to the time we didn't do versioning in
> if-conversion for vectorization (but the testcase relies on AVX512
> support which is newer).

LGTM.

> 2019-04-07  Richard Biener  <rguenther@suse.de>
> 
> 	PR middle-end/89618
> 	* cfgloopmanip.c (copy_loop_info): Copy forgotten fields.
> 	* tree-inline.c (copy_loops): Simplify.
> 
> 	* gcc.target/i386/pr89618.c: New testcase.

	Jakub

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

* Re: [PATCH] Fix PR89618
       [not found] <CAFULd4Z=VQZVxBFtReyPNSKfUzz450z=t4QmF5m=FZ478Kr58g@mail.gmail.com>
@ 2019-03-10 16:49 ` Uros Bizjak
  0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2019-03-10 16:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Guenther, Jakub Jelinek

> This fixes a missed vectorization because loop_version (and in the end
> copy_loop_info) didn't copy IVDEP info (safelen) during if-conversion
> versioning.
>
> Bootstrap & regtest running on x86_64-unknown-linux-gnu.
>
> Even though this isn't a regression I'd like to fix this for GCC 9,
> it may appear as regression to the time we didn't do versioning in
> if-conversion for vectorization (but the testcase relies on AVX512
> support which is newer).
>
> Richard.
>
> 2019-04-07  Richard Biener  <rguenther@suse.de>
>
> PR middle-end/89618
> * cfgloopmanip.c (copy_loop_info): Copy forgotten fields.
> * tree-inline.c (copy_loops): Simplify.
>
> * gcc.target/i386/pr89618.c: New testcase.

This patch caused PR89649 [1].

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89649

Uros.

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

end of thread, other threads:[~2019-03-10 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 12:06 [PATCH] Fix PR89618 Richard Biener
2019-03-07 12:47 ` Jakub Jelinek
     [not found] <CAFULd4Z=VQZVxBFtReyPNSKfUzz450z=t4QmF5m=FZ478Kr58g@mail.gmail.com>
2019-03-10 16:49 ` Uros Bizjak

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