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