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
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 } } */
13 test_000 (int* x
, unsigned int c
)
18 for (i
= 0; i
< c
; ++i
)
19 s
+= ! (x
[i
] & 0x3000);
24 test_001 (int* x
, unsigned int c
)
29 for (i
= 0; i
< c
; ++i
)
30 s
-= ! (x
[i
] & 0x3000);
35 test_002 (int a
, int b
, int c
)
38 return ((a
& b
) != 0) - c
;
42 test_003 (int a
, int b
, int c
)
44 /* 1x tst, 1x movt, 1x sub */
45 return ((a
& b
) == 0) - c
;
49 test_004 (int a
, int b
, int c
)
52 return c
- ((a
& b
) != 0);
56 test_005 (int a
, int b
, int c
)
58 /* 1x shll, 1x subc */
64 test_006 (int a
, int b
, int c
)
66 /* 1x neg, 1x cmp/pl, 1x addc */
73 test_007 (int a
, int b
, int c
)
75 /* 1x add #-1, 1x cmp/eq, 1x addc */
82 test_008 (int a
, int b
, int c
)
84 /* 1x neg, 1x cmp/gt, 1x subc */
91 test_009 (int a
, int b
, int c
, int d
)
93 /* 1x div0s, 1x subc */
94 return c
- d
- (a
< 0 != b
< 0);