diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 02d59e08915a0c5c70496f9a49f44f0744fd6fed..7dd49a719c7e9f1e79515a268eb30c93a06c3ef3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-04  Jan Hubicka  <jh@suse.cz>
+
+	PR middle-end/37343
+	* tree-switch-conversion.c (check_final_bb): Accept only IP
+	invariants.
+
 2008-09-04  Jan Hubicka  <jh@suse.cz>
 
 	* tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges):
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 226a77da0a8caafe45c0c2b26a32d360215c3dc7..5e1b4669c14fb7a67a884ab9bd941a175c54781e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-03  Jan Hubicka  <jh@suse.cz>
+
+	PR middle-end/37343
+	* g++.dg/torture/pr37343.C New file.
+
 2008-09-03  Ira Rosen  <irar@il.ibm.com>
 
 	* gcc.dg/vect/slp-perm-1.c: Add call to check_vect.
@@ -11,7 +16,7 @@
 	PR tree-optimization/37345
 	PR tree-optimization/37358
 	PR tree-optimization/37357
-	* g++.dg/torture/pr37345.c: New file.
+	* g++.dg/torture/pr37345.C: New file.
 
 2008-09-03  Tobias Grosser  <grosser@fim.uni-passau.de>
 
diff --git a/gcc/testsuite/g++.dg/torture/pr37343.C b/gcc/testsuite/g++.dg/torture/pr37343.C
new file mode 100644
index 0000000000000000000000000000000000000000..c4614f39faa491c23bf99daa469376a3ea0550dd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr37343.C
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+typedef enum RW { rwBitmapGrey, rwBitmapGrey16 } RW;
+void FindDepth(RW);
+void ParseDumpBitmap(RW kind, int maxfiles) 
+{
+    static const RW normalTypes[] = { };
+    const RW *bitmapTypes;
+    int i;
+    switch (kind) {
+        case rwBitmapGrey:
+        case rwBitmapGrey16:
+            bitmapTypes = &kind;
+            break;
+        default:
+            bitmapTypes = normalTypes;
+    }
+    for (i = 0; i < maxfiles; i++)
+        FindDepth(bitmapTypes[i]);
+}
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 8bcfcfde5ca031046e3f4c7a799a17a085d061da..e9757454f21923c1197d5098b2e9d841949c396c 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -298,7 +298,7 @@ check_final_bb (void)
 
 	  if ((bb == info.switch_bb
 	       || (single_pred_p (bb) && single_pred (bb) == info.switch_bb))
-	      && !is_gimple_min_invariant (gimple_phi_arg_def (phi, i)))
+	      && !is_gimple_ip_invariant (gimple_phi_arg_def (phi, i)))
 	    {
 	      info.reason = "   Non-invariant value from a case\n";
 	      return false; /* Non-invariant argument.  */