sw_dense_signed.c (684B)
1 /* A dense switch whose case values are contiguous but include negatives, so the 2 * backend must bias the selector before indexing (or build a compare chain). 3 * This complements the existing 0-based dense jumptable case by starting below 4 * zero. volatile selector defeats folding. Selector -1 selects the case 5 * returning 42. Exit code 42. */ 6 int sel(int x) { 7 switch (x) { 8 case -3: 9 return 10; 10 case -2: 11 return 11; 12 case -1: 13 return 42; 14 case 0: 15 return 13; 16 case 1: 17 return 14; 18 case 2: 19 return 15; 20 case 3: 21 return 16; 22 default: 23 return 99; 24 } 25 } 26 int test_main(void) { 27 volatile int x = -1; 28 return sel(x); 29 }