1 /* PR tree-optimization/54579
2 PR middle-end/55299 */
3
4 /* { dg-do compile } */
5 /* { dg-options "-O -fdump-tree-cddce1" } */
6
7 int
asr1(int a,int b)8 asr1 (int a, int b)
9 {
10 return ~((~a) >> b);
11 }
12
13 long
asr1l(long a,long b)14 asr1l (long a, long b)
15 {
16 return ~((~a) >> b);
17 }
18
19 int
asr_conv(unsigned a,unsigned b)20 asr_conv (unsigned a, unsigned b)
21 {
22 return ~((int)~a >> b);
23 }
24
25 unsigned
asr_conv2(unsigned a,unsigned b)26 asr_conv2 (unsigned a, unsigned b)
27 {
28 return ~(unsigned)((int)~a >> b);
29 }
30
31 unsigned
asr_conv3(int a,int b)32 asr_conv3 (int a, int b)
33 {
34 return ~(unsigned)(~a >> b);
35 }
36
37 typedef __INT32_TYPE__ int32_t;
38 typedef __INT64_TYPE__ int64_t;
39
40 int32_t
asr_conv4(int64_t a,int b)41 asr_conv4 (int64_t a, int b)
42 {
43 return ~((int32_t)~a >> b);
44 }
45
46 int32_t
asr_conv5(int64_t a,int b)47 asr_conv5 (int64_t a, int b)
48 {
49 return ~(int32_t)(~a >> b);
50 }
51
52 int
asr2(int a,int b)53 asr2 (int a, int b)
54 {
55 return -((-a - 1) >> b) - 1;
56 }
57
58 int
asr3(int a,int b)59 asr3 (int a, int b)
60 {
61 return a < 0 ? ~((~a) >> b) : a >> b;
62 }
63
64 int64_t
asr3l(int64_t a,int b)65 asr3l (int64_t a, int b)
66 {
67 return a < 0 ? ~((~a) >> b) : a >> b;
68 }
69
70 int
asr4(int a,int b)71 asr4 (int a, int b)
72 {
73 return a < 0 ? -((-a - 1) >> b) - 1 : a >> b;
74 }
75
76 /* { dg-final { scan-tree-dump-times ">>" 11 "cddce1" } } */
77 /* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
78