From 9502376b96e4211926680b3f75996c79f63e676a Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 22 Oct 2026 14:21:14 +0300 Subject: [PATCH] Relaxed v_round vs cvRound checks. --- modules/core/test/test_intrin_utils.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/core/test/test_intrin_utils.hpp b/modules/core/test/test_intrin_utils.hpp index dc5d553cf6..fa810dd269 100644 --- a/modules/core/test/test_intrin_utils.hpp +++ b/modules/core/test/test_intrin_utils.hpp @@ -1539,11 +1539,22 @@ template struct TheTest { LaneType x = dataO[i]; double xd = (double)x; + + // NOTE: Armv7 scalar cvRound and vector v_round may produce different result on the range edges and clams differently + auto check_big_int = [&](int v0, int v) { + constexpr int F2INT_MAX = 2147483520; + if (v0 < F2INT_MAX) { + EXPECT_EQ(v0, v); + } else { + EXPECT_GE(v, F2INT_MAX); + } + }; SCOPED_TRACE(cv::format("overflow: i=%d, x=%g", i, xd)); - EXPECT_EQ(saturate_cast(cvRound(x)), roundO[i]); - EXPECT_EQ(saturate_cast(cvTrunc(x)), truncO[i]); - EXPECT_EQ(saturate_cast(cvFloor(x)), floorO[i]); - EXPECT_EQ(saturate_cast(cvCeil(x)), ceilO[i]); + check_big_int(saturate_cast(cvRound(x)), roundO[i]); + check_big_int(saturate_cast(cvTrunc(x)), truncO[i]); + check_big_int(saturate_cast(cvFloor(x)), floorO[i]); + check_big_int(saturate_cast(cvCeil(x)), ceilO[i]); + if (sizeof(ILaneType) == 4) { if (xd >= 2147483648.)