+2018-09-05 Martin Liska <mliska@suse.cz>
+
+ PR tree-optimization/87205
+ * tree-switch-conversion.c (pass_lower_switch::execute):
+ Group cases for switch statements.
+
2018-09-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/87217
+2018-09-05 Martin Liska <mliska@suse.cz>
+
+ PR tree-optimization/87205
+ * gcc.dg/tree-ssa/pr87205-2.c: New test.
+ * gcc.dg/tree-ssa/pr87205.c: New test.
+
2018-09-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/87217
--- /dev/null
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+void f(int);
+void h(unsigned i)
+{
+ switch (i) {
+ default: __builtin_unreachable();
+ case 0: f(42); break;
+ case 1: f(42); break;
+ case 2: f(42); break;
+ case 3: f(42); break;
+ case 4: f(42); break;
+ case 5: f(42); break;
+ }
+}
+
+/* { dg-final { scan-tree-dump-not "if" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "switch" "optimized" } } */
--- /dev/null
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+void f( int x );
+
+void h( unsigned ix )
+{
+ switch( ix )
+ {
+ case 0: f(42); break;
+ case 1: f(42); break;
+ case 2: f(42); break;
+ case 3: f(42); break;
+ case 4: f(42); break;
+ case 5: f(42); break;
+ default: __builtin_unreachable();
+ }
+}
+
+
+/* { dg-final { scan-tree-dump-not "if" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "switch" "optimized" } } */
FOR_EACH_BB_FN (bb, fun)
{
gimple *stmt = last_stmt (bb);
- if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
- switch_statements.safe_push (stmt);
+ gswitch *swtch;
+ if (stmt && (swtch = dyn_cast<gswitch *> (stmt)))
+ {
+ if (!O0)
+ group_case_labels_stmt (swtch);
+ switch_statements.safe_push (swtch);
+ }
}
for (unsigned i = 0; i < switch_statements.length (); i++)