Patchwork [Cilkplus] Fix pragma simd info being lost

login
register
mail settings
Submitter Iyer, Balaji V
Date Dec. 14, 2012, 4:59 a.m.
Message ID <BF230D13CA30DD48930C31D40993300016CEBE98@FMSMSX102.amr.corp.intel.com>
Download mbox | patch
Permalink /patch/206292/
State New
Headers show

Comments

Iyer, Balaji V - Dec. 14, 2012, 4:59 a.m.
Hello Everyone,
	This patch is for the Cilk Plus branch mainly affecting both C and C++ compilers. Some of the pragma simd structure's indices were getting lost and this patch will restore them. It will also insert the appropriate error messages when assert (in pragma simd) is requested in some places that were omitted.

Thanks,

Balaji V. Iyer.
Jakub Jelinek - Dec. 14, 2012, 4:58 p.m.
On Fri, Dec 14, 2012 at 04:59:02AM +0000, Iyer, Balaji V wrote:
> --- tree-vect-loop.c	(revision 194483)
> +++ tree-vect-loop.c	(working copy)
> @@ -234,8 +234,8 @@
>  		  if (flag_enable_cilk && pragma_simd_assert_requested_p
>  		      (loop->pragma_simd_index))
>  		    {
> -		      error ("Loop not vectorized. " 
> -			     "Exiting as requested by Pragma SIMD");
> +		      fatal_error ("Loop not vectorized. " 
> +				   "Exiting as requested by Pragma SIMD");
>  		    }
>  		  return false;
>  		}

Why do you think fatal_error is the right thing here?  Why doesn't normal
error work?  Generally, if one function contains 10 #pragma simd loops that
require vectorization and 5 out of them aren't vectorized, it is nicer for
users to be told about all 5 of them, rather than just the first one.
fatal_error will exit immediately.

	Jakub
Iyer, Balaji V - Dec. 14, 2012, 5:01 p.m.
Hello Jakub,
	Please see my responses below.

Thanks,

Balaji V. Iyer.

> -----Original Message-----
> From: Jakub Jelinek [mailto:jakub@redhat.com]
> Sent: Friday, December 14, 2012 11:59 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH][Cilkplus] Fix pragma simd info being lost
> 
> On Fri, Dec 14, 2012 at 04:59:02AM +0000, Iyer, Balaji V wrote:
> > --- tree-vect-loop.c	(revision 194483)
> > +++ tree-vect-loop.c	(working copy)
> > @@ -234,8 +234,8 @@
> >  		  if (flag_enable_cilk && pragma_simd_assert_requested_p
> >  		      (loop->pragma_simd_index))
> >  		    {
> > -		      error ("Loop not vectorized. "
> > -			     "Exiting as requested by Pragma SIMD");
> > +		      fatal_error ("Loop not vectorized. "
> > +				   "Exiting as requested by Pragma SIMD");
> >  		    }
> >  		  return false;
> >  		}
> 
> Why do you think fatal_error is the right thing here?  Why doesn't normal error
> work?  Generally, if one function contains 10 #pragma simd loops that require
> vectorization and 5 out of them aren't vectorized, it is nicer for users to be told
> about all 5 of them, rather than just the first one.
> fatal_error will exit immediately.

The #pragma simd assert requires the compiler to halt compilation if the loop is not vectorized. This is why I used fatal_error. The default case is noassert.


> 
> 	Jakub
Jakub Jelinek - Dec. 14, 2012, 5:08 p.m.
On Fri, Dec 14, 2012 at 05:01:48PM +0000, Iyer, Balaji V wrote:
> > Why do you think fatal_error is the right thing here?  Why doesn't normal error
> > work?  Generally, if one function contains 10 #pragma simd loops that require
> > vectorization and 5 out of them aren't vectorized, it is nicer for users to be told
> > about all 5 of them, rather than just the first one.
> > fatal_error will exit immediately.
> 
> The #pragma simd assert requires the compiler to halt compilation if the
> loop is not vectorized.  This is why I used fatal_error.  The default case
> is noassert.

The compilation is halted even with error, compiler will exit with non-zero
exit status, won't compile any further functions, etc.

	Jakub
Iyer, Balaji V - Dec. 14, 2012, 7:38 p.m.
> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> owner@gcc.gnu.org] On Behalf Of Jakub Jelinek
> Sent: Friday, December 14, 2012 12:09 PM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH][Cilkplus] Fix pragma simd info being lost
> 
> On Fri, Dec 14, 2012 at 05:01:48PM +0000, Iyer, Balaji V wrote:
> > > Why do you think fatal_error is the right thing here?  Why doesn't
> > > normal error work?  Generally, if one function contains 10 #pragma
> > > simd loops that require vectorization and 5 out of them aren't
> > > vectorized, it is nicer for users to be told about all 5 of them, rather than just
> the first one.
> > > fatal_error will exit immediately.
> >
> > The #pragma simd assert requires the compiler to halt compilation if
> > the loop is not vectorized.  This is why I used fatal_error.  The
> > default case is noassert.
> 
> The compilation is halted even with error, compiler will exit with non-zero exit
> status, won't compile any further functions, etc.

OK, I will change them and send out another patch.

> 
> 	Jakub

Patch

Index: ChangeLog.cilkplus
===================================================================
--- ChangeLog.cilkplus	(revision 194483)
+++ ChangeLog.cilkplus	(working copy)
@@ -1,3 +1,17 @@ 
+2012-12-13  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+	* tree-vect-loop.c (vect_determine_vectorization_factor): Added a
+	check if assert is requested in simd pragma.
+	(vect_analyze_loop_form): Likewise.
+	(vect_analyze_loop_operations): Likewise.
+	(vect_analyze_loop): Likewise.
+	* tree-cfgcleanup.c (remove_forwarder_block): Copied the pragma
+	simd struct index from the removed bb to the destination basic block.
+	* cfgloop.c (flow_loops_find): Added flag_enable_cilk check.
+	* tree-cfg.c (gimple_merge_blocks): Copied the pragma simd struct
+	index from the source to destination.
+	(remove_bb): Likewise.
+
 2012-12-12  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
 	* c/c-objc-common.h (LANG_HOOKS_CILK_CHECK_CTRL_FLOW): New define.
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 194483)
+++ tree-vect-loop.c	(working copy)
@@ -234,8 +234,8 @@ 
 		  if (flag_enable_cilk && pragma_simd_assert_requested_p
 		      (loop->pragma_simd_index))
 		    {
-		      error ("Loop not vectorized. " 
-			     "Exiting as requested by Pragma SIMD");
+		      fatal_error ("Loop not vectorized. " 
+				   "Exiting as requested by Pragma SIMD");
 		    }
 		  return false;
 		}
@@ -412,8 +412,8 @@ 
 	      if (flag_enable_cilk && pragma_simd_assert_requested_p 
 		  (loop->pragma_simd_index))
 		{
-		  error ("Loop not vectorized. "
-			 "Exiting as requested by PRAGMA SIMD");
+		  fatal_error ("Loop not vectorized. " 
+			       "Exiting as requested by PRAGMA SIMD");
 		}
 	      return false;
 	    }
@@ -429,8 +429,8 @@ 
 	      if (flag_enable_cilk && pragma_simd_assert_requested_p 
 		  (loop->pragma_simd_index))
 		{
-		  error ("Loop not vectorized. "
-			 "Exiting as requested by PRAGMA SIMD");
+		  fatal_error ("Loop not vectorized. " 
+			       "Exiting as requested by PRAGMA SIMD");
 		}
 	      return false;
 	    }
@@ -470,8 +470,8 @@ 
 		  if (flag_enable_cilk && pragma_simd_assert_requested_p 
 		      (loop->pragma_simd_index))
 		    {
-		      error ("Loop not vectorized. "
-			     "Exiting as requested by PRAGMA SIMD");
+		      fatal_error ("Loop not vectorized. " 
+				   "Exiting as requested by PRAGMA SIMD");
 		    }
 		  return false;
 		}
@@ -518,8 +518,8 @@ 
 	      if (flag_enable_cilk && pragma_simd_assert_requested_p 
 		  (loop->pragma_simd_index))
 		{
-		  error ("Loop not vectorized. "
-			 "Exiting as requested by PRAGMA SIMD");
+		  fatal_error ("Loop not vectorized. " 
+			       "Exiting as requested by PRAGMA SIMD");
 		}
 	      return false;
 	    }
@@ -541,8 +541,8 @@ 
 	      if (flag_enable_cilk && pragma_simd_assert_requested_p 
 		  (loop->pragma_simd_index))
 		{
-		  error ("Loop not vectorized. "
-			 "Exiting as requested by PRAGMA SIMD");
+		  fatal_error ("Loop not vectorized. " 
+			       "Exiting as requested by PRAGMA SIMD");
 		}
 	      return false;
 	    }
@@ -607,8 +607,8 @@ 
       if (flag_enable_cilk && pragma_simd_assert_requested_p 
 	  (loop->pragma_simd_index))
 	{
-	  error ("Loop not vectorized. "
-		 "Exiting as requested by Pragma SIMD");
+	  fatal_error ("Loop not vectorized. " 
+		       "Exiting as requested by Pragma SIMD");
 	}
       return false;
     }
@@ -1188,18 +1188,26 @@ 
         {
           if (dump_enabled_p ())
             dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: control flow in loop.");
+			     "not vectorized: control flow in loop."); 
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
           return NULL;
         }
 
       if (empty_block_p (loop->header))
-    {
+	{
           if (dump_enabled_p ())
             dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			     "not vectorized: empty loop.");
-      return NULL;
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
+	  return NULL;
+	}
     }
-    }
   else
     {
       struct loop *innerloop = loop->inner;
@@ -1227,6 +1235,10 @@ 
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			     "not vectorized: multiple nested loops.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
 	  return NULL;
 	}
 
@@ -1237,6 +1249,10 @@ 
 	  if (dump_enabled_p ())
             dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			     "not vectorized: Bad inner loop.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
 	  return NULL;
 	}
 
@@ -1246,6 +1262,10 @@ 
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			     "not vectorized: inner-loop count not invariant.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}
@@ -1255,6 +1275,10 @@ 
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			     "not vectorized: control flow in loop.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
         }
@@ -1271,6 +1295,10 @@ 
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			     "not vectorized: unsupported outerloop form.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}
@@ -1286,11 +1314,21 @@ 
       if (dump_enabled_p ())
         {
           if (!single_exit (loop))
-	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			     "not vectorized: multiple exits.");
+	    { 
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+			       "not vectorized: multiple exits."); 
+	      if (flag_enable_cilk && pragma_simd_assert_requested_p 
+		  (loop->pragma_simd_index)) 
+		fatal_error ("Loop not vectorized. " 
+			     "Exiting as requested by Pragma SIMD"); 
+	    }
           else if (EDGE_COUNT (loop->header->preds) != 2)
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			     "not vectorized: too many incoming edges.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
         }
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
@@ -1307,6 +1345,10 @@ 
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			 "not vectorized: unexpected loop form.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1327,6 +1369,10 @@ 
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			     "not vectorized: abnormal loop exit edge.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
 	  if (inner_loop_vinfo)
 	    destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
@@ -1339,6 +1385,10 @@ 
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			 "not vectorized: complicated exit condition.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1350,6 +1400,10 @@ 
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			 "not vectorized: number of iterations cannot be "
 			 "computed.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1379,6 +1433,10 @@ 
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			 "not vectorized: number of iterations = 0.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
       if (inner_loop_vinfo)
         destroy_loop_vec_info (inner_loop_vinfo, false);
       return NULL;
@@ -1540,6 +1598,10 @@ 
               if (dump_enabled_p ())
 		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 				 "not vectorized: value used after loop.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
               return false;
             }
 
@@ -1550,6 +1612,10 @@ 
               if (dump_enabled_p ())
 		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 				 "not vectorized: scalar dependence cycle.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
               return false;
             }
 
@@ -1568,6 +1634,10 @@ 
 				   "not vectorized: relevant phi not "
 				   "supported: ");
                   dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, phi, 0);
+		  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+		      (loop->pragma_simd_index)) 
+		    fatal_error ("Loop not vectorized. " 
+				 "Exiting as requested by Pragma SIMD"); 
                 }
 	      return false;
             }
@@ -1595,6 +1665,10 @@ 
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			 "not vectorized: redundant loop. no profit to "
 			 "vectorize.");
+      if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	  (loop->pragma_simd_index)) 
+	fatal_error ("Loop not vectorized. " 
+		     "Exiting as requested by Pragma SIMD"); 
       return false;
     }
 
@@ -1616,6 +1690,10 @@ 
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			 "not vectorized: iteration count smaller than "
 			 "vectorization factor.");
+      if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	  (loop->pragma_simd_index)) 
+	fatal_error ("Loop not vectorized. " 
+		     "Exiting as requested by Pragma SIMD"); 
       return false;
     }
 
@@ -1638,6 +1716,10 @@ 
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			 "not vectorized: vector version will never be "
 			 "profitable.");
+      if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	  (loop->pragma_simd_index)) 
+	fatal_error ("Loop not vectorized. " 
+		     "Exiting as requested by Pragma SIMD"); 
       return false;
     }
 
@@ -1665,6 +1747,10 @@ 
 			 "not vectorized: iteration count smaller than user "
 			 "specified loop bound parameter or minimum profitable "
 			 "iterations (whichever is more conservative).");
+      if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	  (loop->pragma_simd_index)) 
+	fatal_error ("Loop not vectorized. " 
+		     "Exiting as requested by Pragma SIMD"); 
       return false;
     }
 
@@ -1682,6 +1768,10 @@ 
                          "than specified loop bound parameter or minimum "
                          "profitable iterations (whichever is more "
                          "conservative).");
+      if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	  (loop->pragma_simd_index)) 
+	fatal_error ("Loop not vectorized. " 
+		     "Exiting as requested by Pragma SIMD"); 
       return false;
     }
 
@@ -1696,6 +1786,10 @@ 
           if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			     "not vectorized: can't create epilog loop 1.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
           return false;
         }
       if (!slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
@@ -1703,6 +1797,10 @@ 
           if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 			     "not vectorized: can't create epilog loop 2.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p 
+	      (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
           return false;
         }
     }
@@ -1735,7 +1833,7 @@ 
     {
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-			 "bad data references.");
+			 "bad data references."); 
       return false;
     }
 
@@ -1903,6 +2001,13 @@ 
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 			     "bad loop form.");
+	  if (flag_enable_cilk && pragma_simd_assert_requested_p
+	      (loop->pragma_simd_index))
+	    {
+	      fatal_error ("Loop not vectorized. " 
+			   "Exiting as requested by Pragma SIMD");
+	    }
+
 	  return NULL;
 	}
 
@@ -1918,8 +2023,13 @@ 
       vector_sizes &= ~current_vector_size;
       if (vector_sizes == 0
 	  || current_vector_size == 0)
-	return NULL;
-
+	{ 
+	  if (flag_enable_cilk 
+	      && pragma_simd_assert_requested_p (loop->pragma_simd_index)) 
+	    fatal_error ("Loop not vectorized. " 
+			 "Exiting as requested by Pragma SIMD"); 
+	  return NULL;
+	}
       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
       if (dump_enabled_p ())
Index: tree-cfgcleanup.c
===================================================================
--- tree-cfgcleanup.c	(revision 194483)
+++ tree-cfgcleanup.c	(working copy)
@@ -346,6 +346,11 @@ 
   if (dest == bb)
     return false;
 
+  if (flag_enable_cilk && bb->pragma_simd_index != 0
+      && (dest->pragma_simd_index == 0
+	  || dest->pragma_simd_index == INVALID_PRAGMA_SIMD_SLOT))
+    dest->pragma_simd_index = bb->pragma_simd_index;
+
   /* If the destination block consists of a nonlocal label or is a
      EH landing pad, do not merge it.  */
   label = first_stmt (dest);
Index: cfgloop.c
===================================================================
--- cfgloop.c	(revision 194483)
+++ cfgloop.c	(working copy)
@@ -423,8 +423,11 @@ 
 	      bitmap_set_bit (headers, header->index);
               /* Here we are going to copy the pragma simd value from 
 		 the latch to the header.  */
-              if ((header->pragma_simd_index == 0)  
-		  && (latch->pragma_simd_index  != 0)) 
+              if (flag_enable_cilk 
+		  && (header->pragma_simd_index == 0 
+		      || header->pragma_simd_index == INVALID_PRAGMA_SIMD_SLOT)
+		  && (latch->pragma_simd_index  != 0 
+		      || latch->pragma_simd_index != INVALID_PRAGMA_SIMD_SLOT))
 		header->pragma_simd_index = latch->pragma_simd_index;
 	      num_loops++;
 	    }
@@ -466,7 +469,8 @@ 
 
 	  loop->header = header;
 	  loop->num = num_loops;
-	  loop->pragma_simd_index = header->pragma_simd_index;
+	  if (flag_enable_cilk)
+	    loop->pragma_simd_index = header->pragma_simd_index;
 
 	  num_loops++;
 
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 194483)
+++ tree-cfg.c	(working copy)
@@ -1631,6 +1631,11 @@ 
   if (dump_file)
     fprintf (dump_file, "Merging blocks %d and %d\n", a->index, b->index);
 
+  if (flag_enable_cilk && b->pragma_simd_index != 0
+      && (a->pragma_simd_index == 0
+	  || a->pragma_simd_index == INVALID_PRAGMA_SIMD_SLOT))
+    a->pragma_simd_index = b->pragma_simd_index;
+
   /* Remove all single-valued PHI nodes from block B of the form
      V_i = PHI <V_j> by propagating V_j to all the uses of V_i.  */
   gsi = gsi_last_bb (a);
@@ -1897,7 +1902,11 @@ 
   remove_phi_nodes_and_edges_for_unreachable_block (bb);
   bb->il.gimple.seq = NULL;
   bb->il.gimple.phi_nodes = NULL;
-  bb->next_bb->pragma_simd_index = bb->pragma_simd_index;
+  if (flag_enable_cilk 
+      && bb->next_bb->pragma_simd_index == 0
+      && bb->pragma_simd_index != 0 
+      && bb->pragma_simd_index != INVALID_PRAGMA_SIMD_SLOT)
+    bb->next_bb->pragma_simd_index = bb->pragma_simd_index;
 }