Hello,

I was relying on the assumption that all case labels in a switch
vector that jump to the same target block would also have the same
CASE_LABEL. This isn't so for the test case of PR53881, where DCE
removes a dead statement but preserves a user label. Fortunately,
using find_edge in emit_case_bit_tests is cheap because we know that
there are very few edges going out of the switch (at most 3) and
usually only one incoming edge per case target.

Bootstrapped on powerpc64-unknown-linux-gnu. Committed as obvious (r189349).

Ciao!
Steven

gcc/
        PR tree-optimization/53881
        * tree-switch-conversion.c (emit_case_bit_tests): Do not rely on
        comparing labels to establish uniqueness of a switch case target,
        use the CFG instead.

testsuite/
        PR tree-optimization/53881
        * gcc.dg/pr53881.c: New test.

Index: gcc/tree-switch-conversion.c
--- trunk/gcc/tree-switch-conversion.c  2012/07/07 12:27:33     189348
+++ trunk/gcc/tree-switch-conversion.c  2012/07/07 12:35:44     189349
@@ -329,14 +329,13 @@
       unsigned int lo, hi;
       tree cs = gimple_switch_label (swtch, i);
       tree label = CASE_LABEL (cs);
+      edge e = find_edge (switch_bb, label_to_block (label));
       for (k = 0; k < count; k++)
-       if (label == test[k].label)
+       if (e == test[k].target_edge)
          break;

       if (k == count)
        {
-         edge e = find_edge (switch_bb, label_to_block (label));
-         gcc_assert (e);
          gcc_checking_assert (count < MAX_CASE_BIT_TESTS);
          test[k].hi = 0;
          test[k].lo = 0;

Reply via email to