https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90340

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Simplified test-case:

$ cat /tmp/csibe.c
int a;

int foo(char c) {
  switch (c) {
  case 'c':
    return a;
  case 's':
    return 3;
  case 'n':
    return 1;
  case '%':
    return -2;
  case 'o':
    return a + 2;
    break;
  case 'X':
  case 'x':
    return 2222;
  case 'd':
  case 'i':
  case 'u':
    return 3333;
  default:
    return 0;
  }
}

$ ~/Programming/bloaty/bloaty bad.o -- good.o 
     VM SIZE                     FILE SIZE
 --------------               --------------
  [ = ]       0 .rela.rodata     +528  [NEW]
  [NEW]    +176 .rodata          +176  [NEW]
  [ = ]       0 [ELF Headers]    +128   +15%
  [ = ]       0 .rela.text        +24   +50%
  [ = ]       0 .symtab           +24 +10.0%
  [ = ]       0 .shstrtab         +13   +15%
  [ = ]       0 [Unmapped]         +5   +62%
  [ = ]       0 .comment          -22 -33.8%
 -20.7%     -28 .text             -28 -20.7%
   +81%    +148 TOTAL            +848   +56%

Where bad.o is GCC 9.1 and good.o is GCC 8.3.1.
Reason is that GCC 9 can newly generate jump tables for a fraction of switch
statement and we allow:

  /* Max growth ratio for code that is optimized for size.  */
  static const unsigned HOST_WIDE_INT max_ratio_for_size = 3;

;; GIMPLE switch case clusters: 37 88 JT(values:8 comparisons:8 range:22
density: 36.36%):99-120 

I can imagine shrinking the parameter to 2 for -Os.
Can you please help me how to run all CSIBE benchmarks?

Reply via email to