http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45830

           Summary: [4.4/4.5/4.6 Regression] Code+rodata increase with
                    -ftree-switch-conversion
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ja...@gcc.gnu.org
                CC: jamb...@gcc.gnu.org


int
foo (int *a)
{
  switch (*a)
    {
    case 0:
    case 3:
    case 1:
    case 2:
    case 4:
    case 23:
    case 26:
    case 19:
    case 5:
    case 21:
    case 20:
    case 22:
    case 27:
      return 1;
    default:
      return 0;
    }
}

generates significantly shorter code+rodata with -fno-tree-switch-conversion
than without.  I guess for the cases where 
      if (CASE_USE_BIT_TESTS
          && ! TREE_CONSTANT (index_expr)
          && compare_tree_int (range, GET_MODE_BITSIZE (word_mode)) < 0
          && compare_tree_int (range, 0) > 0
          && lshift_cheap_p ()
          && ((uniq == 1 && count >= 3)
              || (uniq == 2 && count >= 5)
              || (uniq == 3 && count >= 6)))
is true tree-switch-conversion.c should not perform the optimization, and
in any case the question is if the table needs to be created always for the
type of the constants, even when they are integral and would fit into narrower
integer type (like char/unsigned char in this case).

Reply via email to