Debian Codegraph @

gcc/testsuite/gcc.dg/builtin-stdc-rotate-4.c

raw
1 /* PR c/117456 */
2 /* { dg-do run } */
3 /* { dg-options "-std=c11" } */
4
5 struct S {
6 unsigned s : 5;
7 };
8
9 unsigned
10 f1 (struct S s)
11 {
12 return __builtin_stdc_rotate_left (s.s, 3);
13 }
14
15 unsigned
16 f2 (struct S s, int n)
17 {
18 return __builtin_stdc_rotate_left (s.s, n);
19 }
20
21 unsigned
22 f3 (struct S s)
23 {
24 return __builtin_stdc_rotate_right (s.s, 2);
25 }
26
27 unsigned
28 f4 (struct S s, int n)
29 {
30 return __builtin_stdc_rotate_right (s.s, n);
31 }
32
33 #if __BITINT_MAXWIDTH__ >= 64
34 unsigned _BitInt(5)
35 f5 (unsigned _BitInt(5) s)
36 {
37 return __builtin_stdc_rotate_left (s, 3);
38 }
39
40 unsigned _BitInt(5)
41 f6 (unsigned _BitInt(5) s, int n)
42 {
43 return __builtin_stdc_rotate_left (s, n);
44 }
45
46 unsigned _BitInt(5)
47 f7 (unsigned _BitInt(5) s)
48 {
49 return __builtin_stdc_rotate_right (s, 2);
50 }
51
52 unsigned _BitInt(5)
53 f8 (unsigned _BitInt(5) s, int n)
54 {
55 return __builtin_stdc_rotate_right (s, n);
56 }
57 #endif
58
59 #if __BITINT_MAXWIDTH__ >= 125
60 unsigned _BitInt(125)
61 f9 (unsigned _BitInt(125) s)
62 {
63 return __builtin_stdc_rotate_left (s, 13);
64 }
65
66 unsigned _BitInt(125)
67 f10 (unsigned _BitInt(125) s, int n)
68 {
69 return __builtin_stdc_rotate_left (s, n);
70 }
71
72 unsigned _BitInt(125)
73 f11 (unsigned _BitInt(125) s)
74 {
75 return __builtin_stdc_rotate_right (s, 42);
76 }
77
78 unsigned _BitInt(125)
79 f12 (unsigned _BitInt(125) s, int n)
80 {
81 return __builtin_stdc_rotate_right (s, n);
82 }
83 #endif
84
85 int
86 main ()
87 {
88 struct S s = { 0x12 };
89 if (f1 (s) != 0x14
90 || f2 (s, 0) != 0x12
91 || f2 (s, 2) != 0xa
92 || f2 (s, 1) != 0x5
93 || f3 (s) != 0x14
94 || f4 (s, 0) != 0x12
95 || f4 (s, 2) != 0x14
96 || f4 (s, 1) != 0x9)
97 __builtin_abort ();
98 #if __BITINT_MAXWIDTH__ >= 64
99 if (f5 (0x12uwb) != 0x14uwb
100 || f6 (0x12uwb, 0) != 0x12uwb
101 || f6 (0x12uwb, 2) != 0xauwb
102 || f6 (0x12uwb, 1) != 0x5uwb
103 || f7 (0x12uwb) != 0x14uwb
104 || f8 (0x12uwb, 0) != 0x12uwb
105 || f8 (0x12uwb, 2) != 0x14uwb
106 || f8 (0x12uwb, 1) != 0x9uwb)
107 __builtin_abort ();
108 #endif
109 #if __BITINT_MAXWIDTH__ >= 125
110 if (f9 (12107255122146692213464668179507246062uwb) != 32859299037257821061785486091897129243uwb
111 || f10 (12107255122146692213464668179507246062uwb, 0) != 12107255122146692213464668179507246062uwb
112 || f10 (12107255122146692213464668179507246062uwb, 57) != 786310737972746809290227161460052307uwb
113 || f10 (12107255122146692213464668179507246062uwb, 1) != 24214510244293384426929336359014492124uwb
114 || f11 (12107255122146692213464668179507246062uwb) != 25567301336572975565218391744704605699uwb
115 || f12 (12107255122146692213464668179507246062uwb, 0) != 12107255122146692213464668179507246062uwb
116 || f12 (12107255122146692213464668179507246062uwb, 22) != 27217840477347696606051931660144451082uwb
117 || f12 (12107255122146692213464668179507246062uwb, 1) != 6053627561073346106732334089753623031uwb)
118 __builtin_abort ();
119 #endif
120 }