@samitouri / QOSamiQemu / commits / 97af096c69

tests/tcg/arm: Tests for new FPRCVT instructions

We autodetect the presence of FPRCVT in the test cross compiler, which is a recent feature in GCC and not supported by many distros yet. If this is in place, we compile the existing fcvt.c test with an extra compiler flag which uses the new SIMD instructions; the output from the test is unchanged. The existing [US]CVTF instructions do not have a test, so no new tests are added for the SIMD versions. They have been tested manually to check the new SIMD versions produce the same numerical results as the existing versions. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org> Message-id: 20260630-jmac-fprcvt-v3-6-f4840d5e0a7f@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Jim MacArthur committed Jun 30, 2026 at 14:16 UTC 97af096c69aa65e90b291f5c677eebb6a04fd42c
2 files changed +20 -1
tests/tcg/aarch64/Makefile.target
+13 -1
@@ -28,9 +28,21 @@ config-cc.mak: Makefile
28 $(call cc-option,-march=armv8.5-a, CROSS_CC_HAS_ARMV8_5); \
29 $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \
30 $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \
31 - $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme $$fnia, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak
31 + $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme $$fnia, CROSS_AS_HAS_ARMV9_SME); \
32 + $(call cc-option,-march=armv9-a+fprcvt, CROSS_CC_HAS_ARMV9_FPRCVT)) 3> config-cc.mak
33 -include config-cc.mak
34
35 +ifneq ($(CROSS_CC_HAS_ARMV9_FPRCVT),)
36 +AARCH64_TESTS += fcvt-fprcvt
37 +fcvt-fprcvt: LDFLAGS += -lm
38 +fcvt-fprcvt: CFLAGS += $(CROSS_CC_HAS_ARMV9_FPRCVT) -DFPRCVT
39 +fcvt-fprcvt: fcvt.c
40 + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
41 +run-fcvt-fprcvt: fcvt-fprcvt
42 + $(call run-test,$<,$(QEMU) $<)
43 + $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
44 +endif
45 +
46 ifneq ($(CROSS_CC_HAS_ARMV8_2),)
47 AARCH64_TESTS += dcpop
48 dcpop: CFLAGS += $(CROSS_CC_HAS_ARMV8_2)
tests/tcg/arm/fcvt.c
+7
@@ -171,8 +171,14 @@ static void convert_single_to_integer(void)
171 #if defined(__arm__)
172 /* asm("vcvt.s32.f32 %s0, %s1" : "=t" (output) : "t" (input)); */
173 output = input;
174 +#else
175 +#ifdef FPRCVT
176 + asm("fcvtzs d0, %s1\r\n"
177 + "fmov %0, d0" :
178 + "=r" (output) : "w" (input));
179 #else
180 asm("fcvtzs %0, %s1" : "=r" (output) : "w" (input));
181 +#endif
182 #endif
183 print_int64(i, output);
184 }
@@ -425,6 +431,7 @@ int main(int argc, char *argv[argc])
431 convert_double_to_integer();
432 convert_half_to_integer();
433
434 +
435 /* And now with ARM alternative FP16 */
436 #if defined(__arm__)
437 asm("vmrs r1, fpscr\n\t"