public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR89578
@ 2019-03-07 15:09 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2019-03-07 15:09 UTC (permalink / raw)
  To: gcc-patches


The following fixes PR89578, an optimization regression with the
recent restrict fixes.  The idea is to keep track of the original
function context by attaching that to our loop structure.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

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

	PR middle-end/89578
	* cfgloop.h (struct loop): Add owned_clique field.
	* cfgloopmanip.c (copy_loop_info): Copy it.
	* tree-cfg.c (gimple_duplicate_bb): Do not remap owned_clique
	cliques.
	* tree-inline.c (copy_loops): Remap owned_clique.
	* lto-streamer-in.c (input_cfg): Stream owned_clique.
	* lto-streamer-out.c (output_cfg): Likewise.

Index: gcc/cfgloop.h
===================================================================
--- gcc/cfgloop.h	(revision 269458)
+++ gcc/cfgloop.h	(working copy)
@@ -227,6 +227,10 @@ struct GTY ((chain_next ("%h.next"))) lo
      Other values means unroll with the given unrolling factor.  */
   unsigned short unroll;
 
+  /* If this loop was inlined the main clique of the callee which does
+     not need remapping when copying the loop body.  */
+  unsigned short owned_clique;
+
   /* For SIMD loops, this is a unique identifier of the loop, referenced
      by IFN_GOMP_SIMD_VF, IFN_GOMP_SIMD_LANE and IFN_GOMP_SIMD_LAST_LANE
      builtins.  */
Index: gcc/cfgloopmanip.c
===================================================================
--- gcc/cfgloopmanip.c	(revision 269458)
+++ gcc/cfgloopmanip.c	(working copy)
@@ -1024,6 +1024,7 @@ copy_loop_info (struct loop *loop, struc
   target->force_vectorize = loop->force_vectorize;
   target->in_oacc_kernels_region = loop->in_oacc_kernels_region;
   target->unroll = loop->unroll;
+  target->owned_clique = loop->owned_clique;
 }
 
 /* Copies copy of LOOP as subloop of TARGET loop, placing newly
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 269458)
+++ gcc/tree-cfg.c	(working copy)
@@ -6244,7 +6244,8 @@ gimple_duplicate_bb (basic_block bb, cop
 	      op = TREE_OPERAND (op, 0);
 	    if ((TREE_CODE (op) == MEM_REF
 		 || TREE_CODE (op) == TARGET_MEM_REF)
-		&& MR_DEPENDENCE_CLIQUE (op) > 1)
+		&& MR_DEPENDENCE_CLIQUE (op) > 1
+		&& MR_DEPENDENCE_CLIQUE (op) != bb->loop_father->owned_clique)
 	      {
 		if (!id->dependence_map)
 		  id->dependence_map = new hash_map<dependence_hash,
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 269458)
+++ gcc/tree-inline.c	(working copy)
@@ -2670,6 +2670,11 @@ copy_loops (copy_body_data *id,
 	    cfun->has_unroll = true;
 	  if (dest_loop->force_vectorize)
 	    cfun->has_force_vectorize_loops = true;
+	  if (id->src_cfun->last_clique != 0)
+	    dest_loop->owned_clique
+	      = remap_dependence_clique (id,
+					 src_loop->owned_clique
+					 ? src_loop->owned_clique : 1);
 
 	  /* Finally place it into the loop array and the loop tree.  */
 	  place_new_loop (cfun, dest_loop);
Index: gcc/lto-streamer-in.c
===================================================================
--- gcc/lto-streamer-in.c	(revision 269458)
+++ gcc/lto-streamer-in.c	(working copy)
@@ -826,6 +826,7 @@ input_cfg (struct lto_input_block *ib, s
       /* Read OMP SIMD related info.  */
       loop->safelen = streamer_read_hwi (ib);
       loop->unroll = streamer_read_hwi (ib);
+      loop->owned_clique = streamer_read_hwi (ib);
       loop->dont_vectorize = streamer_read_hwi (ib);
       loop->force_vectorize = streamer_read_hwi (ib);
       loop->simduid = stream_read_tree (ib, data_in);
Index: gcc/lto-streamer-out.c
===================================================================
--- gcc/lto-streamer-out.c	(revision 269458)
+++ gcc/lto-streamer-out.c	(working copy)
@@ -1938,6 +1938,7 @@ output_cfg (struct output_block *ob, str
       /* Write OMP SIMD related info.  */
       streamer_write_hwi (ob, loop->safelen);
       streamer_write_hwi (ob, loop->unroll);
+      streamer_write_hwi (ob, loop->owned_clique);
       streamer_write_hwi (ob, loop->dont_vectorize);
       streamer_write_hwi (ob, loop->force_vectorize);
       stream_write_tree (ob, loop->simduid, true);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-07 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 15:09 [PATCH] Fix PR89578 Richard Biener

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