1 /* PR middle-end/62263 */
2 /* PR middle-end/82498 */
3 /* { dg-do compile } */
4 /* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
5 /* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 23 "optimized" } } */
6 /* { dg-final { scan-tree-dump-not "PHI <" "optimized" } } */
8 #if __SIZEOF_INT__ == 2
9 #define LARGE_UNSIGNED 0x1234U
11 #define LARGE_UNSIGNED 0x12345678U
15 f1 (unsigned int x
, unsigned char y
)
17 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
18 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
22 f2 (unsigned int x
, signed char y
)
24 y
&= __CHAR_BIT__
* __SIZEOF_INT__
- 1;
25 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
29 f3 (unsigned int x
, unsigned char y
)
31 return (x
<< (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))));
35 f4 (unsigned int x
, unsigned char y
)
37 y
= y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1);
38 return y
? (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
)) : x
;
42 f5 (unsigned int x
, unsigned char y
)
44 y
= y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1);
45 return (x
<< y
) | (x
>> ((__CHAR_BIT__
* __SIZEOF_INT__
- y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
49 f6 (unsigned int x
, unsigned char y
)
51 return (x
<< (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (x
>> ((__CHAR_BIT__
* __SIZEOF_INT__
- (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
55 f7 (unsigned int x
, unsigned char y
)
57 return (x
<< (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (x
>> ((__CHAR_BIT__
* __SIZEOF_INT__
- y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
61 f8 (unsigned int x
, unsigned char y
)
63 return (x
<< (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (x
>> ((-y
) & (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
67 f9 (unsigned int x
, int y
)
69 return (LARGE_UNSIGNED
<< (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (LARGE_UNSIGNED
>> (-y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
73 f10 (unsigned int x
, int y
)
75 return (LARGE_UNSIGNED
>> (-y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (LARGE_UNSIGNED
<< (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
79 f11 (unsigned int x
, int y
)
81 return (LARGE_UNSIGNED
>> (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (LARGE_UNSIGNED
<< (-y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
85 f12 (unsigned int x
, int y
)
87 return (LARGE_UNSIGNED
<< (-y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1))) | (LARGE_UNSIGNED
>> (y
& (__CHAR_BIT__
* __SIZEOF_INT__
- 1)));
91 f13 (unsigned x
, unsigned char y
)
95 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
96 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
100 f14 (unsigned x
, unsigned y
)
104 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
105 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
109 f15 (unsigned x
, unsigned short y
)
113 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
114 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
118 f16 (unsigned x
, unsigned char y
)
120 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
123 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
127 f17 (unsigned x
, unsigned y
)
129 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
132 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
136 f18 (unsigned x
, unsigned short y
)
138 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
141 return (x
<< y
) | (x
>> (__CHAR_BIT__
* __SIZEOF_INT__
- y
));
145 f19 (unsigned x
, unsigned char y
)
147 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
148 return (x
<< y
) | (x
>> (((unsigned char) -y
) % (__CHAR_BIT__
* __SIZEOF_INT__
)));
152 f20 (unsigned x
, unsigned int y
)
154 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
155 return (x
<< y
) | (x
>> (-y
% (__CHAR_BIT__
* __SIZEOF_INT__
)));
159 f21 (unsigned x
, unsigned short y
)
161 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
162 return (x
<< y
) | (x
>> (((unsigned short) -y
) % (__CHAR_BIT__
* __SIZEOF_INT__
)));
166 f22 (unsigned x
, unsigned char y
)
168 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
169 return (x
<< y
) | (x
>> (-y
& ((__CHAR_BIT__
* __SIZEOF_INT__
) - 1)));
173 f23 (unsigned x
, unsigned short y
)
175 y
%= __CHAR_BIT__
* __SIZEOF_INT__
;
176 return (x
<< y
) | (x
>> (-y
& ((__CHAR_BIT__
* __SIZEOF_INT__
) - 1)));