| 1 |
/* Tests to check the utilization of the addc instruction in special cases. |
| 2 |
If everything works as expected we won't see any movt instructions in |
| 3 |
these cases. */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-O1" } */ |
| 6 |
|
| 7 |
/* { dg-final { scan-assembler-times "addc" 36 } } */ |
| 8 |
/* { dg-final { scan-assembler-times "shll" 14 } } */ |
| 9 |
/* { dg-final { scan-assembler-times "add\tr" 12 } } */ |
| 10 |
/* { dg-final { scan-assembler-not "movt" } } */ |
| 11 |
|
| 12 |
/* { dg-final { scan-assembler-times "add\t#1" 1 } } */ |
| 13 |
|
| 14 |
/* { dg-final { scan-assembler-times "mov\t#-2" 1 { target { ! sh2a } } } } */ |
| 15 |
/* { dg-final { scan-assembler-times "and\tr" 1 { target { ! sh2a } } } } */ |
| 16 |
|
| 17 |
/* { dg-final { scan-assembler-times "bclr\t#0" 1 { target { sh2a } } } } */ |
| 18 |
|
| 19 |
/* { dg-final { scan-assembler-times "shlr" 22 { target { ! sh2a } } } } */ |
| 20 |
/* { dg-final { scan-assembler-not "shlr" { target { sh2a } } } } */ |
| 21 |
|
| 22 |
int |
| 23 |
test_000 (int a, int c, int b, int d) |
| 24 |
{ |
| 25 |
// 1x shlr/bld, 1x addc |
| 26 |
return a + (b & 1); |
| 27 |
} |
| 28 |
|
| 29 |
int |
| 30 |
test_001 (int a, int c, int b, int d) |
| 31 |
{ |
| 32 |
// 1x shlr/bld, 1x addc |
| 33 |
return a + b + (c & 1); |
| 34 |
} |
| 35 |
|
| 36 |
int |
| 37 |
test_002 (int a, int c, int b, int d) |
| 38 |
{ |
| 39 |
// 1x shlr/bld, 1x add, 1x addc |
| 40 |
return a + b + c + (d & 1); |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
test_003 (int a, int c, int b, int d) |
| 45 |
{ |
| 46 |
// 1x shlr/bld, 1x addc |
| 47 |
return (b & 1) + a; |
| 48 |
} |
| 49 |
|
| 50 |
int |
| 51 |
test_004 (int a, int c, int b, int d) |
| 52 |
{ |
| 53 |
// 1x shlr/bld, 1x addc |
| 54 |
return a + (c & 1) + b; |
| 55 |
} |
| 56 |
|
| 57 |
int |
| 58 |
test_005 (int a, int c, int b, int d) |
| 59 |
{ |
| 60 |
// 1x shlr/bld, 1x add, 1x addc |
| 61 |
return a + b + (d & 1) + c; |
| 62 |
} |
| 63 |
|
| 64 |
int |
| 65 |
test_006 (int a, int c, int b, int d) |
| 66 |
{ |
| 67 |
// 1x shlr/bld, 1x addc |
| 68 |
return (c & 1) + a + b; |
| 69 |
} |
| 70 |
|
| 71 |
int |
| 72 |
test_007 (int a, int c, int b, int d) |
| 73 |
{ |
| 74 |
// 1x shlr/bld, 1x add, 1x addc |
| 75 |
return a + (d & 1) + b + c; |
| 76 |
} |
| 77 |
|
| 78 |
int |
| 79 |
test_008 (int a, int c, int b, int d) |
| 80 |
{ |
| 81 |
// 1x shlr/bld, 1x add, 1x addc |
| 82 |
return (d & 1) + a + b + c; |
| 83 |
} |
| 84 |
|
| 85 |
int |
| 86 |
test_009 (int a, int c, int b, int d) |
| 87 |
{ |
| 88 |
// 1x shlr/bld, 1x addc |
| 89 |
return a + b + (b & 1); |
| 90 |
} |
| 91 |
|
| 92 |
int |
| 93 |
test_010 (int a, int c, int b, int d) |
| 94 |
{ |
| 95 |
// 1x shlr/bld, 1x addc |
| 96 |
return a + (b & 1) + b; |
| 97 |
} |
| 98 |
|
| 99 |
int |
| 100 |
test_011 (int a, int c, int b, int d) |
| 101 |
{ |
| 102 |
// 1x shlr/bld, 1x addc |
| 103 |
return (b & 1) + a + b; |
| 104 |
} |
| 105 |
|
| 106 |
int |
| 107 |
test_012 (int a, int c, int b, int d) |
| 108 |
{ |
| 109 |
// 1x shlr/bld, 1x add, 1x addc |
| 110 |
return a + b + d + (b & 1); |
| 111 |
} |
| 112 |
|
| 113 |
int |
| 114 |
test_013 (int a, int c, int b, int d) |
| 115 |
{ |
| 116 |
// 1x shlr/bld, 1x add, 1x addc |
| 117 |
return a + d + (b & 1) + b; |
| 118 |
} |
| 119 |
|
| 120 |
int |
| 121 |
test_014 (int a, int c, int b, int d) |
| 122 |
{ |
| 123 |
// 1x shlr/bld, 1x add, 1x addc |
| 124 |
return a + (b & 1) + d + b; |
| 125 |
} |
| 126 |
|
| 127 |
int |
| 128 |
test_015 (int a, int c, int b, int d) |
| 129 |
{ |
| 130 |
// 1x shlr/bld, 1x add, 1x addc |
| 131 |
return (b & 1) + a + d + b; |
| 132 |
} |
| 133 |
|
| 134 |
int |
| 135 |
test_016 (int a, int b, int c, int d) |
| 136 |
{ |
| 137 |
// non-SH2A: 1x add #1, 1x mov #-2, 1x and |
| 138 |
// SH2A: 1x add #1, 1x bclr #0 |
| 139 |
return a + (a & 1); |
| 140 |
} |
| 141 |
|
| 142 |
int |
| 143 |
test_017 (int a, int b, int c, int d) |
| 144 |
{ |
| 145 |
// 1x shlr/bld, 1x addc |
| 146 |
return a + a + (a & 1); |
| 147 |
} |
| 148 |
|
| 149 |
int |
| 150 |
test_018 (int a, int b, int c, int d) |
| 151 |
{ |
| 152 |
// 1x shlr/bld, 1x addc |
| 153 |
return a + (a & 1) + a; |
| 154 |
} |
| 155 |
|
| 156 |
int |
| 157 |
test_019 (int a, int b, int c, int d) |
| 158 |
{ |
| 159 |
// 1x shlr/bld, 1x addc |
| 160 |
return (a & 1) + a + a; |
| 161 |
} |
| 162 |
|
| 163 |
int |
| 164 |
test_020 (int a, int b, int c, int d) |
| 165 |
{ |
| 166 |
// 1x shlr/bld, 1x addc |
| 167 |
return b + b + (a & 1); |
| 168 |
} |
| 169 |
|
| 170 |
int |
| 171 |
test_021 (int a, int b, int c, int d) |
| 172 |
{ |
| 173 |
// 1x shlr/bld, 1x addc |
| 174 |
return b + (a & 1) + b; |
| 175 |
} |
| 176 |
|
| 177 |
int |
| 178 |
test_022 (int a, int b, int c, int d) |
| 179 |
{ |
| 180 |
// 1x shlr/bld, 1x addc |
| 181 |
return (a & 1) + b + b; |
| 182 |
} |
| 183 |
|
| 184 |
int |
| 185 |
test_023 (int a, int b, int c, int d) |
| 186 |
{ |
| 187 |
// 1x shll, 1x addc |
| 188 |
return a + ((b >> 31) & 1); |
| 189 |
} |
| 190 |
|
| 191 |
int |
| 192 |
test_024 (int a, int b, int c, int d) |
| 193 |
{ |
| 194 |
// 1x shll, 1x addc |
| 195 |
return ((b >> 31) & 1) + a; |
| 196 |
} |
| 197 |
|
| 198 |
int |
| 199 |
test_025 (int a, int b, int c, int d) |
| 200 |
{ |
| 201 |
// 1x shll, 1x addc |
| 202 |
return ((a >> 31) & 1) + a; |
| 203 |
} |
| 204 |
|
| 205 |
int |
| 206 |
test_026 (int a, int b, int c, int d) |
| 207 |
{ |
| 208 |
// 1x shll, 1x addc |
| 209 |
return a + ((a >> 31) & 1); |
| 210 |
} |
| 211 |
|
| 212 |
int |
| 213 |
test_027 (int a, int b, int c, int d) |
| 214 |
{ |
| 215 |
// 1x shll, 1x addc |
| 216 |
return a + b + ((c >> 31) & 1); |
| 217 |
} |
| 218 |
|
| 219 |
int |
| 220 |
test_028 (int a, int b, int c, int d) |
| 221 |
{ |
| 222 |
// 1x shll, 1x addc |
| 223 |
return a + ((c >> 31) & 1) + b; |
| 224 |
} |
| 225 |
|
| 226 |
int |
| 227 |
test_029 (int a, int b, int c, int d) |
| 228 |
{ |
| 229 |
// 1x shll, 1x addc |
| 230 |
return ((c >> 31) & 1) + a + b; |
| 231 |
} |
| 232 |
|
| 233 |
int |
| 234 |
test_030 (int a, int b, int c, int d) |
| 235 |
{ |
| 236 |
// 1x shll, 1x addc, 1x add |
| 237 |
return a + b + c + ((d >> 31) & 1); |
| 238 |
} |
| 239 |
|
| 240 |
int |
| 241 |
test_031 (int a, int b, int c, int d) |
| 242 |
{ |
| 243 |
// 1x shll, 1x addc, 1x add |
| 244 |
return a + b + ((d >> 31) & 1) + c; |
| 245 |
} |
| 246 |
|
| 247 |
int |
| 248 |
test_032 (int a, int b, int c, int d) |
| 249 |
{ |
| 250 |
// 1x shll, 1x addc, 1x add |
| 251 |
return a + ((d >> 31) & 1) + b + c; |
| 252 |
} |
| 253 |
|
| 254 |
int |
| 255 |
test_033 (int a, int b, int c, int d) |
| 256 |
{ |
| 257 |
// 1x shll, 1x addc, 1x add |
| 258 |
return ((d >> 31) & 1) + a + b + c; |
| 259 |
} |
| 260 |
|
| 261 |
int |
| 262 |
test_034 (int a, int b, int c, int d) |
| 263 |
{ |
| 264 |
// 1x shll, 1x addc |
| 265 |
return a + a + ((d >> 31) & 1); |
| 266 |
} |
| 267 |
|
| 268 |
int |
| 269 |
test_035 (int a, int b, int c, int d) |
| 270 |
{ |
| 271 |
// 1x shll, 1x addc |
| 272 |
return a + ((d >> 31) & 1) + a; |
| 273 |
} |
| 274 |
|
| 275 |
int |
| 276 |
test_036 (int a, int b, int c, int d) |
| 277 |
{ |
| 278 |
// 1x shll, 1x addc |
| 279 |
return ((d >> 31) & 1) + a + a; |
| 280 |
} |