2 This test is meant to test the backend's generation of
3 non-destructive and available on some architectures.
4 Also serves as a regression test for bug #3534833.
9 /* Some architectures have non-destructive and when one operand is a literal with exactly one bit set (e.g. all Z80-related ) */
10 int litbitchar (unsigned char a
)
12 register unsigned char b
= a
+ 1; /* Suggest allocating b to accumulator */
24 /* Some architectures have non-destructive and when one operand is a literal with exactly one bit set, and the other operand can be in any register or even spilt (e.g. S08) */
25 int litbitchar2 (unsigned char a
, unsigned char c
, unsigned char e
)
27 unsigned char b
= a
+ 1;
28 unsigned char d
= c
+ 1;
54 /* Some architectures have non-destructive and when one operand is a literal with at most one bit per byte set (e.g. Z80) */
55 int litbitint (unsigned int a
)
57 register unsigned int b
= a
+ 1; /* Suggest allocating b to accumulator */
69 /* Some architectures have non-destructive and when one operand is a one-byte literal (e.g. Z180) */
70 int litchar (unsigned char a
)
72 register unsigned char b
= a
+ 1; /* Suggest allocating b to accumulator */
84 /* Some architectures have non-destructive and when one operand is in a register (e.g. Z180) */
85 int regchar (unsigned char a
, unsigned char c
)
87 register unsigned char b
= a
+ 1; /* Suggest allocating b to accumulator */
88 register unsigned char d
= c
+ 1;
100 void testAndSurvive (void)
102 ASSERT (litbitchar (0x77u
- 1) == 0);
103 ASSERT (litbitchar (0x74u
- 1) == 1);
104 ASSERT (litbitchar (0x70u
- 1) == 2);
105 ASSERT (litbitchar (0x80u
- 1) == 3);
107 ASSERT (litbitchar2 (0x01u
- 1, 0x01u
- 1, 0x01u
) == 8);
108 ASSERT (litbitchar2 (0x01u
- 1, 0x80u
- 1, 0x01u
) == 10);
109 ASSERT (litbitchar2 (0x74u
- 1, 0x01u
- 1, 0x01u
) == 1);
110 ASSERT (litbitchar2 (0x80u
- 1, 0x01u
- 1, 0x01u
) == 3);
111 ASSERT (litbitchar2 (0x20u
- 1, 0x01u
- 1, 0x04u
) == 5);
113 ASSERT (litbitint (0x0001u
- 1) == 0);
114 ASSERT (litbitint (0x8fe8u
- 1) == 3);
115 ASSERT (litbitint (0x3030u
- 1) == 2);
117 ASSERT (litchar (0x77u
- 1) == 0);
118 ASSERT (litchar (0x88u
- 1) == 2);
119 ASSERT (litchar (0x48u
- 1) == 1);
120 ASSERT (litchar (0x80u
- 1) == 3);
122 ASSERT (regchar (0x77u
- 1, 0x00u
- 1) == 0);
123 ASSERT (regchar (0x88u
- 1, 0x08u
- 1) == 1);
124 #ifndef __SDCC_pdk14 // Those tests would pass, we just don't have enough space in code memory to fit them in together with the others.
125 ASSERT (regchar (0x80u
- 1, 0x88u
- 1) == 1);
126 ASSERT (regchar (0x80u
- 1, 0x08u
- 1) == 3);