| 1 |
/* Tests to check the utilization of the addc and subc instructions. |
| 2 |
If everything works as expected we won't see any movt instructions in |
| 3 |
these cases. */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-O2" } */ |
| 6 |
/* { dg-final { scan-assembler-times "addc" 4 } } */ |
| 7 |
/* { dg-final { scan-assembler-times "subc" 5 } } */ |
| 8 |
/* { dg-final { scan-assembler-times "movt" 1 } } */ |
| 9 |
/* { dg-final { scan-assembler-times "sub\t" 1 } } */ |
| 10 |
/* { dg-final { scan-assembler-times "neg\t" 2 } } */ |
| 11 |
|
| 12 |
int |
| 13 |
test_000 (int* x, unsigned int c) |
| 14 |
{ |
| 15 |
/* 1x addc */ |
| 16 |
int s = 0; |
| 17 |
unsigned int i; |
| 18 |
for (i = 0; i < c; ++i) |
| 19 |
s += ! (x[i] & 0x3000); |
| 20 |
return s; |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
test_001 (int* x, unsigned int c) |
| 25 |
{ |
| 26 |
/* 1x subc */ |
| 27 |
int s = 0; |
| 28 |
unsigned int i; |
| 29 |
for (i = 0; i < c; ++i) |
| 30 |
s -= ! (x[i] & 0x3000); |
| 31 |
return s; |
| 32 |
} |
| 33 |
|
| 34 |
int |
| 35 |
test_002 (int a, int b, int c) |
| 36 |
{ |
| 37 |
/* 1x tst, 1x subc */ |
| 38 |
return ((a & b) != 0) - c; |
| 39 |
} |
| 40 |
|
| 41 |
int |
| 42 |
test_003 (int a, int b, int c) |
| 43 |
{ |
| 44 |
/* 1x tst, 1x movt, 1x sub */ |
| 45 |
return ((a & b) == 0) - c; |
| 46 |
} |
| 47 |
|
| 48 |
int |
| 49 |
test_004 (int a, int b, int c) |
| 50 |
{ |
| 51 |
/* 1x tst, 1x addc */ |
| 52 |
return c - ((a & b) != 0); |
| 53 |
} |
| 54 |
|
| 55 |
int |
| 56 |
test_005 (int a, int b, int c) |
| 57 |
{ |
| 58 |
/* 1x shll, 1x subc */ |
| 59 |
int x = a < 0; |
| 60 |
return c - (b + x); |
| 61 |
} |
| 62 |
|
| 63 |
int |
| 64 |
test_006 (int a, int b, int c) |
| 65 |
{ |
| 66 |
/* 1x neg, 1x cmp/pl, 1x addc */ |
| 67 |
int x = a > 0; |
| 68 |
int y = b + x; |
| 69 |
return y - c; |
| 70 |
} |
| 71 |
|
| 72 |
int |
| 73 |
test_007 (int a, int b, int c) |
| 74 |
{ |
| 75 |
/* 1x add #-1, 1x cmp/eq, 1x addc */ |
| 76 |
int x = a != 1; |
| 77 |
int y = b - x; |
| 78 |
return c + y; |
| 79 |
} |
| 80 |
|
| 81 |
int |
| 82 |
test_008 (int a, int b, int c) |
| 83 |
{ |
| 84 |
/* 1x neg, 1x cmp/gt, 1x subc */ |
| 85 |
int x = a > 1; |
| 86 |
int y = b - x; |
| 87 |
return c + y; |
| 88 |
} |
| 89 |
|
| 90 |
int |
| 91 |
test_009 (int a, int b, int c, int d) |
| 92 |
{ |
| 93 |
/* 1x div0s, 1x subc */ |
| 94 |
return c - d - (a < 0 != b < 0); |
| 95 |
} |