[gcc]
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr54236-3.c
blobcd3d35323d4e229dea7b2e053ec5b965be496d3c
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 } } */
12 int
13 test_000 (int* x, unsigned int c)
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;
23 int
24 test_001 (int* x, unsigned int c)
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;
34 int
35 test_002 (int a, int b, int c)
37 /* 1x tst, 1x subc */
38 return ((a & b) != 0) - c;
41 int
42 test_003 (int a, int b, int c)
44 /* 1x tst, 1x movt, 1x sub */
45 return ((a & b) == 0) - c;
48 int
49 test_004 (int a, int b, int c)
51 /* 1x tst, 1x addc */
52 return c - ((a & b) != 0);
55 int
56 test_005 (int a, int b, int c)
58 /* 1x shll, 1x subc */
59 int x = a < 0;
60 return c - (b + x);
63 int
64 test_006 (int a, int b, int c)
66 /* 1x neg, 1x cmp/pl, 1x addc */
67 int x = a > 0;
68 int y = b + x;
69 return y - c;
72 int
73 test_007 (int a, int b, int c)
75 /* 1x add #-1, 1x cmp/eq, 1x addc */
76 int x = a != 1;
77 int y = b - x;
78 return c + y;
81 int
82 test_008 (int a, int b, int c)
84 /* 1x neg, 1x cmp/gt, 1x subc */
85 int x = a > 1;
86 int y = b - x;
87 return c + y;
90 int
91 test_009 (int a, int b, int c, int d)
93 /* 1x div0s, 1x subc */
94 return c - d - (a < 0 != b < 0);