[gomp4/cilkplus] special case NE_EXPR for omp4 loops
diff mbox

Message ID 51B625FF.8060300@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez June 10, 2013, 7:16 p.m. UTC
Hi Jakub.

In contrast to OMP4+, Cilk Plus allows a "!=" in the condition to a simd 
for loop (we are guaranteed no unsigned wrap around).

I'm not totally happy with the cleanliness of this patch, but the 
alternative seems a lot more convoluted.  Type checking before hand, 
should guarantee that we don't get a NE_EXPR incorrectly (both for Cilk 
Plus and OMP).  I guess we could add some sort of annotation to the 
OMP_SIMD that lets us know we were originally a Cilk Plus construct, but 
that hardly seems worth the effort for handling this case.  Although, 
there could be more things to come ??, though none come to mind right now.

Anyway, this patch fixes the last remaining testsuite failure for both 
C/C++: c-c++-common/cilk-plus/PS/for5.c.

If you hate this too much, I can work on an alternative approach, 
otherwise I'll queue it up with my patchset sitting on top of your gomp4 
branch (my aldyh/cilk-in-gomp branch).



diff mbox

diff --git a/gcc/ChangeLog.cilkplus b/gcc/ChangeLog.cilkplus
index 96a02c6..6a48ada 100644
--- a/gcc/ChangeLog.cilkplus
+++ b/gcc/ChangeLog.cilkplus
@@ -3,6 +3,7 @@ 
 	* Makefile.in (C_COMMON_OBJS): Depend on c-family/c-cilkplus.o.
 	(c-cilkplus.o): New dependency.
+	* omp-low.c (extract_omp_for_data): Add case for NE_EXPR.
 	* c-cilkplus.c: New.
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b131cde..08ed83b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -316,6 +316,12 @@  extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd,
 	case LT_EXPR:
 	case GT_EXPR:
+	case NE_EXPR:
+	  if (!flag_enable_cilk)
+	    gcc_unreachable ();
+	  /* NE_EXPR is technically not allowed in OpenMP, but it is
+	     allowed in Cilk Plus, which generates OMP_SIMD constructs.  */
+	  break;
 	case LE_EXPR:
 	  if (POINTER_TYPE_P (TREE_TYPE (loop->n2)))
 	    loop->n2 = fold_build_pointer_plus_hwi_loc (loc, loop->n2, 1);