| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-switchconv -mbmi" } */ |
| 3 |
|
| 4 |
/* Checks that the exponential index transformation is done for all these types |
| 5 |
of the index variable: |
| 6 |
- (unsigned) char |
| 7 |
- (unsigned) short |
| 8 |
- (unsigned) int |
| 9 |
- (unsigned) long |
| 10 |
- (unsigned) long long */ |
| 11 |
|
| 12 |
int unopt_char(char bit_position) |
| 13 |
{ |
| 14 |
switch (bit_position) |
| 15 |
{ |
| 16 |
case (1 << 0): |
| 17 |
return 0; |
| 18 |
case (1 << 1): |
| 19 |
return 1; |
| 20 |
case (1 << 2): |
| 21 |
return 2; |
| 22 |
case (1 << 3): |
| 23 |
return 3; |
| 24 |
case (1 << 4): |
| 25 |
return 4; |
| 26 |
case (1 << 5): |
| 27 |
return 5; |
| 28 |
case (1 << 6): |
| 29 |
return 6; |
| 30 |
default: |
| 31 |
return 0; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
int unopt_unsigned_char(unsigned char bit_position) |
| 36 |
{ |
| 37 |
switch (bit_position) |
| 38 |
{ |
| 39 |
case (1 << 0): |
| 40 |
return 0; |
| 41 |
case (1 << 1): |
| 42 |
return 1; |
| 43 |
case (1 << 2): |
| 44 |
return 2; |
| 45 |
case (1 << 3): |
| 46 |
return 3; |
| 47 |
case (1 << 4): |
| 48 |
return 4; |
| 49 |
case (1 << 5): |
| 50 |
return 5; |
| 51 |
case (1 << 6): |
| 52 |
return 6; |
| 53 |
default: |
| 54 |
return 0; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
int unopt_short(short bit_position) |
| 59 |
{ |
| 60 |
switch (bit_position) |
| 61 |
{ |
| 62 |
case (1 << 0): |
| 63 |
return 0; |
| 64 |
case (1 << 1): |
| 65 |
return 1; |
| 66 |
case (1 << 2): |
| 67 |
return 2; |
| 68 |
case (1 << 3): |
| 69 |
return 3; |
| 70 |
case (1 << 4): |
| 71 |
return 4; |
| 72 |
case (1 << 5): |
| 73 |
return 5; |
| 74 |
case (1 << 6): |
| 75 |
return 6; |
| 76 |
default: |
| 77 |
return 0; |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
int unopt_unsigned_short(unsigned short bit_position) |
| 82 |
{ |
| 83 |
switch (bit_position) |
| 84 |
{ |
| 85 |
case (1 << 0): |
| 86 |
return 0; |
| 87 |
case (1 << 1): |
| 88 |
return 1; |
| 89 |
case (1 << 2): |
| 90 |
return 2; |
| 91 |
case (1 << 3): |
| 92 |
return 3; |
| 93 |
case (1 << 4): |
| 94 |
return 4; |
| 95 |
case (1 << 5): |
| 96 |
return 5; |
| 97 |
case (1 << 6): |
| 98 |
return 6; |
| 99 |
default: |
| 100 |
return 0; |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
int unopt_int(int bit_position) |
| 105 |
{ |
| 106 |
switch (bit_position) |
| 107 |
{ |
| 108 |
case (1 << 0): |
| 109 |
return 0; |
| 110 |
case (1 << 1): |
| 111 |
return 1; |
| 112 |
case (1 << 2): |
| 113 |
return 2; |
| 114 |
case (1 << 3): |
| 115 |
return 3; |
| 116 |
case (1 << 4): |
| 117 |
return 4; |
| 118 |
case (1 << 5): |
| 119 |
return 5; |
| 120 |
case (1 << 6): |
| 121 |
return 6; |
| 122 |
default: |
| 123 |
return 0; |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
int unopt_unsigned_int(unsigned int bit_position) |
| 128 |
{ |
| 129 |
switch (bit_position) |
| 130 |
{ |
| 131 |
case (1 << 0): |
| 132 |
return 0; |
| 133 |
case (1 << 1): |
| 134 |
return 1; |
| 135 |
case (1 << 2): |
| 136 |
return 2; |
| 137 |
case (1 << 3): |
| 138 |
return 3; |
| 139 |
case (1 << 4): |
| 140 |
return 4; |
| 141 |
case (1 << 5): |
| 142 |
return 5; |
| 143 |
case (1 << 6): |
| 144 |
return 6; |
| 145 |
default: |
| 146 |
return 0; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
int unopt_long(long bit_position) |
| 151 |
{ |
| 152 |
switch (bit_position) |
| 153 |
{ |
| 154 |
case (1 << 0): |
| 155 |
return 0; |
| 156 |
case (1 << 1): |
| 157 |
return 1; |
| 158 |
case (1 << 2): |
| 159 |
return 2; |
| 160 |
case (1 << 3): |
| 161 |
return 3; |
| 162 |
case (1 << 4): |
| 163 |
return 4; |
| 164 |
case (1 << 5): |
| 165 |
return 5; |
| 166 |
case (1 << 6): |
| 167 |
return 6; |
| 168 |
default: |
| 169 |
return 0; |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
int unopt_unsigned_long(unsigned long bit_position) |
| 174 |
{ |
| 175 |
switch (bit_position) |
| 176 |
{ |
| 177 |
case (1 << 0): |
| 178 |
return 0; |
| 179 |
case (1 << 1): |
| 180 |
return 1; |
| 181 |
case (1 << 2): |
| 182 |
return 2; |
| 183 |
case (1 << 3): |
| 184 |
return 3; |
| 185 |
case (1 << 4): |
| 186 |
return 4; |
| 187 |
case (1 << 5): |
| 188 |
return 5; |
| 189 |
case (1 << 6): |
| 190 |
return 6; |
| 191 |
default: |
| 192 |
return 0; |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
#ifdef __x86_64__ |
| 197 |
|
| 198 |
int unopt_long_long(long long bit_position) |
| 199 |
{ |
| 200 |
switch (bit_position) |
| 201 |
{ |
| 202 |
case (1 << 0): |
| 203 |
return 0; |
| 204 |
case (1 << 1): |
| 205 |
return 1; |
| 206 |
case (1 << 2): |
| 207 |
return 2; |
| 208 |
case (1 << 3): |
| 209 |
return 3; |
| 210 |
case (1 << 4): |
| 211 |
return 4; |
| 212 |
case (1 << 5): |
| 213 |
return 5; |
| 214 |
case (1 << 6): |
| 215 |
return 6; |
| 216 |
default: |
| 217 |
return 0; |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
int unopt_unsigned_long_long(unsigned long long bit_position) |
| 222 |
{ |
| 223 |
switch (bit_position) |
| 224 |
{ |
| 225 |
case (1 << 0): |
| 226 |
return 0; |
| 227 |
case (1 << 1): |
| 228 |
return 1; |
| 229 |
case (1 << 2): |
| 230 |
return 2; |
| 231 |
case (1 << 3): |
| 232 |
return 3; |
| 233 |
case (1 << 4): |
| 234 |
return 4; |
| 235 |
case (1 << 5): |
| 236 |
return 5; |
| 237 |
case (1 << 6): |
| 238 |
return 6; |
| 239 |
default: |
| 240 |
return 0; |
| 241 |
} |
| 242 |
} |
| 243 |
|
| 244 |
#endif |
| 245 |
|
| 246 |
/* { dg-final { scan-tree-dump-times "Applying exponential index transform" 8 "switchconv" { target ia32 } } } */ |
| 247 |
/* { dg-final { scan-tree-dump-times "Applying exponential index transform" 10 "switchconv" { target { ! ia32 } } } } */ |