xref: /openbmc/qemu/tests/tcg/x86_64/test-2413.c (revision 0ea0538f)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* Copyright 2024 Linaro, Ltd. */
3 /* See https://gitlab.com/qemu-project/qemu/-/issues/2413 */
4 
5 #include <assert.h>
6 
7 void test(unsigned long *a, unsigned long *d, unsigned long c)
8 {
9     asm("xorl %%eax, %%eax\n\t"
10         "xorl %%edx, %%edx\n\t"
11         "testb $0x20, %%cl\n\t"
12         "sete %%al\n\t"
13         "setne %%dl\n\t"
14         "shll %%cl, %%eax\n\t"
15         "shll %%cl, %%edx\n\t"
16         : "=a"(*a), "=d"(*d)
17         : "c"(c));
18 }
19 
20 int main(void)
21 {
22     unsigned long a, c, d;
23 
24     for (c = 0; c < 64; c++) {
25         test(&a, &d, c);
26         assert(a == (c & 0x20 ? 0 : 1u << (c & 0x1f)));
27         assert(d == (c & 0x20 ? 1u << (c & 0x1f) : 0));
28     }
29     return 0;
30 }
31