1 /* Tests to check the utilization of the addc instruction in special cases.
2 If everything works as expected we won't see any movt instructions in
4 /* { dg-do compile } */
5 /* { dg-options "-O1" } */
6 /* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */
7 /* { dg-final { scan-assembler-times "addc" 37 } } */
8 /* { dg-final { scan-assembler-times "shlr" 23 } } */
9 /* { dg-final { scan-assembler-times "shll" 14 } } */
10 /* { dg-final { scan-assembler-times "add\t" 12 } } */
11 /* { dg-final { scan-assembler-not "movt" } } */
14 test_000 (int a
, int c
, int b
, int d
)
21 test_001 (int a
, int c
, int b
, int d
)
24 return a
+ b
+ (c
& 1);
28 test_002 (int a
, int c
, int b
, int d
)
30 // 1x shlr, 1x add, 1x addc
31 return a
+ b
+ c
+ (d
& 1);
35 test_003 (int a
, int c
, int b
, int d
)
42 test_004 (int a
, int c
, int b
, int d
)
45 return a
+ (c
& 1) + b
;
49 test_005 (int a
, int c
, int b
, int d
)
51 // 1x shlr, 1x add, 1x addc
52 return a
+ b
+ (d
& 1) + c
;
56 test_006 (int a
, int c
, int b
, int d
)
59 return (c
& 1) + a
+ b
;
63 test_007 (int a
, int c
, int b
, int d
)
65 // 1x shlr, 1x add, 1x addc
66 return a
+ (d
& 1) + b
+ c
;
70 test_008 (int a
, int c
, int b
, int d
)
72 // 1x shlr, 1x add, 1x addc
73 return (d
& 1) + a
+ b
+ c
;
77 test_009 (int a
, int c
, int b
, int d
)
80 return a
+ b
+ (b
& 1);
84 test_010 (int a
, int c
, int b
, int d
)
87 return a
+ (b
& 1) + b
;
91 test_011 (int a
, int c
, int b
, int d
)
94 return (b
& 1) + a
+ b
;
98 test_012 (int a
, int c
, int b
, int d
)
100 // 1x shlr, 1x add, 1x addc
101 return a
+ b
+ d
+ (b
& 1);
105 test_013 (int a
, int c
, int b
, int d
)
107 // 1x shlr, 1x add, 1x addc
108 return a
+ d
+ (b
& 1) + b
;
112 test_014 (int a
, int c
, int b
, int d
)
114 // 1x shlr, 1x add, 1x addc
115 return a
+ (b
& 1) + d
+ b
;
119 test_015 (int a
, int c
, int b
, int d
)
121 // 1x shlr, 1x add, 1x addc
122 return (b
& 1) + a
+ d
+ b
;
126 test_016 (int a
, int b
, int c
, int d
)
133 test_017 (int a
, int b
, int c
, int d
)
136 return a
+ a
+ (a
& 1);
140 test_018 (int a
, int b
, int c
, int d
)
143 return a
+ (a
& 1) + a
;
147 test_019 (int a
, int b
, int c
, int d
)
150 return (a
& 1) + a
+ a
;
154 test_020 (int a
, int b
, int c
, int d
)
157 return b
+ b
+ (a
& 1);
161 test_021 (int a
, int b
, int c
, int d
)
164 return b
+ (a
& 1) + b
;
168 test_022 (int a
, int b
, int c
, int d
)
171 return (a
& 1) + b
+ b
;
175 test_023 (int a
, int b
, int c
, int d
)
178 return a
+ ((b
>> 31) & 1);
182 test_024 (int a
, int b
, int c
, int d
)
185 return ((b
>> 31) & 1) + a
;
189 test_025 (int a
, int b
, int c
, int d
)
192 return ((a
>> 31) & 1) + a
;
196 test_026 (int a
, int b
, int c
, int d
)
199 return a
+ ((a
>> 31) & 1);
203 test_027 (int a
, int b
, int c
, int d
)
206 return a
+ b
+ ((c
>> 31) & 1);
210 test_028 (int a
, int b
, int c
, int d
)
213 return a
+ ((c
>> 31) & 1) + b
;
217 test_029 (int a
, int b
, int c
, int d
)
220 return ((c
>> 31) & 1) + a
+ b
;
224 test_030 (int a
, int b
, int c
, int d
)
226 // 1x shll, 1x addc, 1x add
227 return a
+ b
+ c
+ ((d
>> 31) & 1);
231 test_031 (int a
, int b
, int c
, int d
)
233 // 1x shll, 1x addc, 1x add
234 return a
+ b
+ ((d
>> 31) & 1) + c
;
238 test_032 (int a
, int b
, int c
, int d
)
240 // 1x shll, 1x addc, 1x add
241 return a
+ ((d
>> 31) & 1) + b
+ c
;
245 test_033 (int a
, int b
, int c
, int d
)
247 // 1x shll, 1x addc, 1x add
248 return ((d
>> 31) & 1) + a
+ b
+ c
;
252 test_034 (int a
, int b
, int c
, int d
)
255 return a
+ a
+ ((d
>> 31) & 1);
259 test_035 (int a
, int b
, int c
, int d
)
262 return a
+ ((d
>> 31) & 1) + a
;
266 test_036 (int a
, int b
, int c
, int d
)
269 return ((d
>> 31) & 1) + a
+ a
;