[tuples] gimplify_modify_expr_to_memcpy & misc openmp fixes

Aldy Hernandez aldyh@redhat.com
Tue May 20 20:46:00 GMT 2008


gimplify_modify_expr_to_memcpy() was failing to fully gimplify
MODIFY_EXPRs being converted into memcpy() in certain cases.  This patch
fixes the problem.

I fixed a similar problem with gimplify_omp_for().

And I also fixed some problems in omp-low.c where we were overwriting a
GIMPLE_BIND's variables instead of appending them.

All this brings us down to 56 gomp.exp errors in the testsuite, down
from-- oh, a couple hundred.

There are 19 distinct errors left in the gcc.dg/gomp.exp suite.

Yay progress.

Committing to branch.

	* omp-low.c (lower_omp_single): Append to bind variables.
	(lower_omp_master): Same.
	(lower_omp_ordered): Same.
	(lower_omp_critical): Same.
	* gimplify.c (gimplify_modify_expr_to_memcpy): Make sure we are
	fully gimplified.
	(gimplify_omp_for): Same.
	* gimple.h (gimple_bind_set_vars): New.

Index: omp-low.c
===================================================================
--- omp-low.c	(revision 135576)
+++ omp-low.c	(working copy)
@@ -4593,7 +4593,7 @@ lower_omp_single (gimple_stmt_iterator *
 
   pop_gimplify_context (bind);
 
-  gimple_bind_set_vars (bind, ctx->block_vars);
+  gimple_bind_append_vars (bind, ctx->block_vars);
   BLOCK_VARS (block) = ctx->block_vars;
   gsi_replace (gsi_p, bind, true);
 }
@@ -4632,7 +4632,7 @@ lower_omp_master (gimple_stmt_iterator *
 
   pop_gimplify_context (bind);
 
-  gimple_bind_set_vars (bind, ctx->block_vars);
+  gimple_bind_append_vars (bind, ctx->block_vars);
   BLOCK_VARS (block) = ctx->block_vars;
   gsi_replace (gsi_p, bind, true);
 }
@@ -4667,7 +4667,7 @@ lower_omp_ordered (gimple_stmt_iterator 
 
   pop_gimplify_context (bind);
 
-  gimple_bind_set_vars (bind, ctx->block_vars);
+  gimple_bind_append_vars (bind, ctx->block_vars);
   BLOCK_VARS (block) = gimple_bind_vars (bind);
   gsi_replace (gsi_p, bind, true);
 }
@@ -4758,7 +4758,7 @@ lower_omp_critical (gimple_stmt_iterator
   gimple_bind_add_stmt (bind, gimple_build_omp_return (true));
 
   pop_gimplify_context (bind);
-  gimple_bind_set_vars (bind, ctx->block_vars);
+  gimple_bind_append_vars (bind, ctx->block_vars);
   BLOCK_VARS (block) = gimple_bind_vars (bind);
   gsi_replace (gsi_p, bind, true);
 }
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 135576)
+++ gimplify.c	(working copy)
@@ -2972,7 +2972,13 @@ gimplify_modify_expr_to_memcpy (tree *ex
   from = GENERIC_TREE_OPERAND (*expr_p, 1);
 
   from_ptr = build_fold_addr_expr (from);
+  if (!is_gimple_operand (from_ptr))
+    gimplify_expr (&from_ptr, seq_p, NULL, is_gimple_lvalue, fb_lvalue);
+
   to_ptr = build_fold_addr_expr (to);
+  if (!is_gimple_lvalue (to_ptr))
+    gimplify_expr (&to_ptr, seq_p, NULL, is_gimple_lvalue, fb_lvalue);
+
   t = implicit_built_in_decls[BUILT_IN_MEMCPY];
 
   gs = gimple_build_call (t, 3, to_ptr, from_ptr, size);
@@ -5643,6 +5649,10 @@ gimplify_omp_for (tree *expr_p, gimple_s
 	default:
 	  gcc_unreachable ();
 	}
+
+      ret |= gimplify_expr (&TREE_OPERAND (t, 1), &for_pre_body, NULL,
+			    is_gimple_val, fb_rvalue);
+
       for_incr = OMP_FOR_INCR (for_stmt);
 
       break;
@@ -5662,7 +5672,7 @@ gimplify_omp_for (tree *expr_p, gimple_s
     (pre_p, gimple_build_omp_for (for_body, OMP_FOR_CLAUSES (for_stmt),
 				  for_index, for_initial, for_final, for_incr,
 				  for_pre_body, for_predicate));
-  return GS_ALL_DONE;
+  return ret == GS_ALL_DONE ? GS_ALL_DONE : GS_ERROR;
 }
 
 /* Gimplify the gross structure of other OpenMP worksharing constructs.
Index: gimple.h
===================================================================
--- gimple.h	(revision 135576)
+++ gimple.h	(working copy)
@@ -1991,6 +1991,17 @@ gimple_bind_set_vars (gimple gs, tree va
 }
 
 
+/* Append VARS to the set of variables declared in the GIMPLE_BIND
+   statement GS.  */
+
+static inline void
+gimple_bind_append_vars (gimple gs, tree vars)
+{
+  GIMPLE_CHECK (gs, GIMPLE_BIND);
+  gs->gimple_bind.vars = chainon (gs->gimple_bind.vars, vars);
+}
+
+
 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS.  */
 
 static inline gimple_seq



More information about the Gcc-patches mailing list