qemu/tests/tcg/x86_64/test-2175.c
Richard Henderson 83a3a20e59 target/i386: Fix carry flag for BLSI
BLSI has inverted semantics for C as compared to the other two
BMI1 instructions, BLSMSK and BLSR.  Introduce CC_OP_BLSI* for
this purpose.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2175
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240801075845.573075-3-richard.henderson@linaro.org>
2024-08-21 09:11:26 +10:00

25 lines
500 B
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/* See https://gitlab.com/qemu-project/qemu/-/issues/2185 */
#include <assert.h>
int test_setc(unsigned int x, unsigned int y)
{
asm("blsi %1, %0; setc %b0" : "+r"(x) : "r"(y));
return (unsigned char)x;
}
int test_pushf(unsigned int x, unsigned int y)
{
asm("blsi %1, %0; pushf; pop %q0" : "+r"(x) : "r"(y));
return x & 1;
}
int main()
{
assert(test_setc(1, 0xedbf530a));
assert(test_pushf(1, 0xedbf530a));
return 0;
}