[committed] Fix GIMPLE_SWITCH regimplification (PR middle-end/38676)

Jakub Jelinek jakub@redhat.com
Tue Dec 30 23:36:00 GMT 2008


Hi!

If gimple_regimplify_operands is called on GIMPLE_SWITCH, it ICEs, because
no gimplification context has case_labels set.  Only the index
might need regimplification, so this patch regimplifies just that
and leaves all the case labels alone.

Bootstrapped/regtested on x86_64-linux, committed to trunk.

2008-12-31  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/38676
	* gimplify.c (gimple_regimplify_operands): For GIMPLE_SWITCH
	only regimplify switch index.

	* gcc.dg/gomp/pr38676.c: New test.

--- gcc/gimplify.c.jj	2008-12-16 09:48:41.000000000 +0100
+++ gcc/gimplify.c	2008-12-30 22:58:50.000000000 +0100
@@ -7380,6 +7380,10 @@ gimple_regimplify_operands (gimple stmt,
       gimplify_expr (gimple_cond_rhs_ptr (stmt), &pre, NULL,
 		     is_gimple_val, fb_rvalue);
       break;
+    case GIMPLE_SWITCH:
+      gimplify_expr (gimple_switch_index_ptr (stmt), &pre, NULL,
+		     is_gimple_val, fb_rvalue);
+      break;
     case GIMPLE_OMP_ATOMIC_LOAD:
       gimplify_expr (gimple_omp_atomic_load_rhs_ptr (stmt), &pre, NULL,
 		     is_gimple_val, fb_rvalue);
--- gcc/testsuite/gcc.dg/gomp/pr38676.c.jj	2008-12-30 23:03:10.000000000 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr38676.c	2008-12-30 22:55:32.000000000 +0100
@@ -0,0 +1,19 @@
+/* PR middle-end/38676 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int
+main ()
+{
+  int bar, foo = 1;
+#pragma omp parallel for shared(foo)
+  for (bar = 0; bar < 3; bar++)
+    {
+      switch (foo)
+	{
+	case 1:
+	  break;
+	}
+    }
+  return 0;
+}

	Jakub



More information about the Gcc-patches mailing list