Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/pr61055.c

raw
1 /* { dg-do run { target { ! avr_tiny } } } */
2 /* { dg-options { -fno-peephole2 } } */
3
4 #include <stdlib.h>
5
6 typedef __UINT16_TYPE__ uint16_t;
7 typedef __INT16_TYPE__ int16_t;
8 typedef __UINT8_TYPE__ uint8_t;
9
10 uint8_t __attribute__((noipa))
11 fun_inc (uint8_t c0)
12 {
13 register uint8_t c asm ("r15") = c0;
14
15 /* Force target value into R15 (lower register) */
16 asm ("" : "+l" (c));
17
18 c++;
19 if (c >= 0x80)
20 c = 0;
21
22 asm ("" : "+l" (c));
23
24 return c;
25 }
26
27 uint8_t __attribute__((noipa))
28 fun_dec (uint8_t c0)
29 {
30 register uint8_t c asm ("r15") = c0;
31
32 /* Force target value into R15 (lower register) */
33 asm ("" : "+l" (c));
34
35 c--;
36 if (c < 0x80)
37 c = 0;
38
39 asm ("" : "+l" (c));
40
41 return c;
42 }
43
44
45 uint8_t __attribute__((noipa))
46 fun_neg (uint8_t c0)
47 {
48 register uint8_t c asm ("r15") = c0;
49
50 c = -c;
51 if (c >= 0x80)
52 c = 0;
53
54 return c;
55 }
56
57 uint16_t __attribute__((noipa))
58 fun_adiw (uint16_t c0)
59 {
60 register uint16_t c asm ("r24") = c0;
61
62 /* Force target value into R24 (for ADIW) */
63 asm ("" : "+r" (c));
64
65 c += 2;
66 if (c >= 0x8000)
67 c = 0;
68
69 asm ("" : "+r" (c));
70
71 return c;
72 }
73
74
75 int main()
76 {
77 if (fun_inc (0x7f) != 0)
78 abort();
79
80 if (fun_neg (0x80) != 0)
81 abort();
82
83 if (fun_adiw (0x7ffe) != 0)
84 abort();
85
86 exit (0);
87 return 0;
88 }