PR target/83368
[official-gcc.git] / gcc / testsuite / gcc.dg / fold-notshift-1.c
blob2de236fc4d8ae870375ec657d1e947af45e79043
1 /* PR tree-optimization/54579
2 PR middle-end/55299 */
4 /* { dg-do compile } */
5 /* { dg-options "-O -fdump-tree-cddce1" } */
7 int
8 asr1 (int a, int b)
10 return ~((~a) >> b);
13 long
14 asr1l (long a, long b)
16 return ~((~a) >> b);
19 int
20 asr_conv (unsigned a, unsigned b)
22 return ~((int)~a >> b);
25 unsigned
26 asr_conv2 (unsigned a, unsigned b)
28 return ~(unsigned)((int)~a >> b);
31 unsigned
32 asr_conv3 (int a, int b)
34 return ~(unsigned)(~a >> b);
37 typedef __INT32_TYPE__ int32_t;
38 typedef __INT64_TYPE__ int64_t;
40 int32_t
41 asr_conv4 (int64_t a, int b)
43 return ~((int32_t)~a >> b);
46 int32_t
47 asr_conv5 (int64_t a, int b)
49 return ~(int32_t)(~a >> b);
52 int
53 asr2 (int a, int b)
55 return -((-a - 1) >> b) - 1;
58 int
59 asr3 (int a, int b)
61 return a < 0 ? ~((~a) >> b) : a >> b;
64 int64_t
65 asr3l (int64_t a, int b)
67 return a < 0 ? ~((~a) >> b) : a >> b;
70 int
71 asr4 (int a, int b)
73 return a < 0 ? -((-a - 1) >> b) - 1 : a >> b;
76 /* { dg-final { scan-tree-dump-times ">>" 11 "cddce1" } } */
77 /* { dg-final { scan-tree-dump-not "~" "cddce1" } } */