From f4eb6fde8f0254a94cb2784144a64d4a0e857e3f Mon Sep 17 00:00:00 2001 From: Aleksi Sapon Date: Thu, 9 Jan 2025 16:23:56 -0500 Subject: [PATCH] llvmpipe: LLVM v2f32 trunc/floor/ceil/nearbyint generates optimal x86 code since at least version 8 Based on the tests committed here: https://github.com/llvm/llvm-project/commit/f9afee479fb6a626445a58c32c8998963dc4968b Reviewed-by: Konstantin Seurer Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 7 ++++--- src/gallium/drivers/llvmpipe/lp_test_arit.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index cb33061cf2e..991d4163f72 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -1861,9 +1861,10 @@ static bool arch_rounding_available(const struct lp_type type) { if ((util_get_cpu_caps()->has_sse4_1 && - (type.length == 1 || type.width*type.length == 128)) || - (util_get_cpu_caps()->has_avx && type.width*type.length == 256) || - (util_get_cpu_caps()->has_avx512f && type.width*type.length == 512)) + (type.length == 1 || (LLVM_VERSION_MAJOR >= 8 && type.length == 2) || + type.width * type.length == 128)) || + (util_get_cpu_caps()->has_avx && type.width * type.length == 256) || + (util_get_cpu_caps()->has_avx512f && type.width * type.length == 512)) return true; else if ((util_get_cpu_caps()->has_altivec && (type.width == 32 && type.length == 4))) diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c index 4c3ef64affe..44d416236dc 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c @@ -477,9 +477,10 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test, unsigned continue; } - if (!util_get_cpu_caps()->has_neon && + if (test->ref == &nearbyintf && length == 2 && + !util_get_cpu_caps()->has_neon && util_get_cpu_caps()->family != CPU_S390X && - test->ref == &nearbyintf && length == 2 && + !(util_get_cpu_caps()->has_sse4_1 && LLVM_VERSION_MAJOR >= 8) && ref != roundf(testval)) { /* FIXME: The generic (non SSE) path in lp_build_iround, which is * always taken for length==2 regardless of native round support,