1 /* PR target/82498 */
2 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
3 /* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */
4
5 #include <x86intrin.h>
6
7 volatile unsigned int a;
8 volatile unsigned long long b;
9 volatile int c;
10
11 int
main()12 main ()
13 {
14 a = 0x12345678U;
15 a = __rold (a, 0);
16 if (a != 0x12345678U)
17 __builtin_abort ();
18 a = __rold (a, 32);
19 if (a != 0x12345678U)
20 __builtin_abort ();
21 a = __rold (a, -32);
22 if (a != 0x12345678U)
23 __builtin_abort ();
24 a = __rold (a, 37);
25 if (a != 0x468acf02U)
26 __builtin_abort ();
27 a = __rold (a, -5);
28 if (a != 0x12345678U)
29 __builtin_abort ();
30 a = __rord (a, 0);
31 if (a != 0x12345678U)
32 __builtin_abort ();
33 a = __rord (a, 32);
34 if (a != 0x12345678U)
35 __builtin_abort ();
36 a = __rord (a, -32);
37 if (a != 0x12345678U)
38 __builtin_abort ();
39 a = __rord (a, -37);
40 if (a != 0x468acf02U)
41 __builtin_abort ();
42 a = __rord (a, 5);
43 if (a != 0x12345678U)
44 __builtin_abort ();
45 c = 0;
46 a = __rold (a, c);
47 if (a != 0x12345678U)
48 __builtin_abort ();
49 c = 32;
50 a = __rold (a, c);
51 if (a != 0x12345678U)
52 __builtin_abort ();
53 c = -32;
54 a = __rold (a, c);
55 if (a != 0x12345678U)
56 __builtin_abort ();
57 c = 37;
58 a = __rold (a, c);
59 if (a != 0x468acf02U)
60 __builtin_abort ();
61 c = -5;
62 a = __rold (a, c);
63 if (a != 0x12345678U)
64 __builtin_abort ();
65 c = 0;
66 a = __rord (a, c);
67 if (a != 0x12345678U)
68 __builtin_abort ();
69 c = 32;
70 a = __rord (a, c);
71 if (a != 0x12345678U)
72 __builtin_abort ();
73 c = -32;
74 a = __rord (a, c);
75 if (a != 0x12345678U)
76 __builtin_abort ();
77 c = -37;
78 a = __rord (a, c);
79 if (a != 0x468acf02U)
80 __builtin_abort ();
81 c = 5;
82 a = __rord (a, c);
83 if (a != 0x12345678U)
84 __builtin_abort ();
85 #ifdef __x86_64__
86 b = 0x123456789abcdef1ULL;
87 b = __rolq (b, 0);
88 if (b != 0x123456789abcdef1ULL)
89 __builtin_abort ();
90 b = __rolq (b, 64);
91 if (b != 0x123456789abcdef1ULL)
92 __builtin_abort ();
93 b = __rolq (b, -64);
94 if (b != 0x123456789abcdef1ULL)
95 __builtin_abort ();
96 b = __rolq (b, 69);
97 if (b != 0x468acf13579bde22ULL)
98 __builtin_abort ();
99 b = __rolq (b, -5);
100 if (b != 0x123456789abcdef1ULL)
101 __builtin_abort ();
102 b = __rorq (b, 0);
103 if (b != 0x123456789abcdef1ULL)
104 __builtin_abort ();
105 b = __rorq (b, 64);
106 if (b != 0x123456789abcdef1ULL)
107 __builtin_abort ();
108 b = __rorq (b, -64);
109 if (b != 0x123456789abcdef1ULL)
110 __builtin_abort ();
111 b = __rorq (b, -69);
112 if (b != 0x468acf13579bde22ULL)
113 __builtin_abort ();
114 b = __rorq (b, 5);
115 if (b != 0x123456789abcdef1ULL)
116 __builtin_abort ();
117 c = 0;
118 b = __rolq (b, c);
119 if (b != 0x123456789abcdef1ULL)
120 __builtin_abort ();
121 c = 64;
122 b = __rolq (b, c);
123 if (b != 0x123456789abcdef1ULL)
124 __builtin_abort ();
125 c = -64;
126 b = __rolq (b, c);
127 if (b != 0x123456789abcdef1ULL)
128 __builtin_abort ();
129 c = 69;
130 b = __rolq (b, c);
131 if (b != 0x468acf13579bde22ULL)
132 __builtin_abort ();
133 c = -5;
134 b = __rolq (b, c);
135 if (b != 0x123456789abcdef1ULL)
136 __builtin_abort ();
137 c = 0;
138 b = __rorq (b, c);
139 if (b != 0x123456789abcdef1ULL)
140 __builtin_abort ();
141 c = 64;
142 b = __rorq (b, c);
143 if (b != 0x123456789abcdef1ULL)
144 __builtin_abort ();
145 c = -64;
146 b = __rorq (b, c);
147 if (b != 0x123456789abcdef1ULL)
148 __builtin_abort ();
149 c = -69;
150 b = __rorq (b, c);
151 if (b != 0x468acf13579bde22ULL)
152 __builtin_abort ();
153 c = 5;
154 b = __rorq (b, c);
155 if (b != 0x123456789abcdef1ULL)
156 __builtin_abort ();
157 #endif
158 return 0;
159 }
160