| 1 |
/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-switchlower1 --param case-values-threshold=4" } */ |
| 3 |
|
| 4 |
int global; |
| 5 |
|
| 6 |
int foo (int x) |
| 7 |
{ |
| 8 |
switch (x) { |
| 9 |
case 0: |
| 10 |
case 10: |
| 11 |
case 1000: |
| 12 |
case 1010: |
| 13 |
case 1025 ... 1030: |
| 14 |
return 1; |
| 15 |
default: |
| 16 |
return 0; |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: 0 10 BT:1000-1030" "switchlower1" } } */ |
| 21 |
|
| 22 |
int foo2 (int x) |
| 23 |
{ |
| 24 |
switch (x) { |
| 25 |
case -100: |
| 26 |
case 100: |
| 27 |
case 1000: |
| 28 |
case 10000: |
| 29 |
case 100000: |
| 30 |
return 1; |
| 31 |
default: |
| 32 |
return 0; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: -100 100 1000 10000 100000" "switchlower1" } } */ |
| 37 |
|
| 38 |
int foo3 (int x) |
| 39 |
{ |
| 40 |
switch (x) { |
| 41 |
case 0: |
| 42 |
case 10: |
| 43 |
case 20: |
| 44 |
global += 1; |
| 45 |
return 3; |
| 46 |
case 30: |
| 47 |
case 33 ... 55: |
| 48 |
case 57: |
| 49 |
return 4; |
| 50 |
case 60 ... 62: |
| 51 |
return 1; |
| 52 |
default: |
| 53 |
return 0; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-62" "switchlower1" } } */ |
| 58 |
|
| 59 |
int foo4 (int x) |
| 60 |
{ |
| 61 |
switch (x) { |
| 62 |
case -100: |
| 63 |
case 10: |
| 64 |
case 20: |
| 65 |
global += 1; |
| 66 |
return 3; |
| 67 |
case 30: |
| 68 |
case 33 ... 55: |
| 69 |
case 57: |
| 70 |
return 4; |
| 71 |
case 60 ... 62: |
| 72 |
return 1; |
| 73 |
case 600 ... 700: |
| 74 |
return 12; |
| 75 |
default: |
| 76 |
return 0; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: -100 BT:10-62 600-700" "switchlower1" } } */ |
| 81 |
|
| 82 |
int foo5 (int x) |
| 83 |
{ |
| 84 |
switch (x) { |
| 85 |
case 10: |
| 86 |
case 20: |
| 87 |
global += 1; |
| 88 |
return 3; |
| 89 |
case 30: |
| 90 |
case 33 ... 55: |
| 91 |
case 57: |
| 92 |
return 4; |
| 93 |
case 60 ... 62: |
| 94 |
return 1; |
| 95 |
case 600 ... 700: |
| 96 |
return 12; |
| 97 |
case 1000 ... 1010: |
| 98 |
case 1012: |
| 99 |
return 333; |
| 100 |
case 1019: |
| 101 |
case 1021: |
| 102 |
return 9; |
| 103 |
case 111111: |
| 104 |
return 3; |
| 105 |
default: |
| 106 |
return 0; |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:10-62 600-700 JT:1000-1021 111111" "switchlower1" } } */ |