util: Implement util_iround with lrintf unconditionally
authorYonggang Luo <luoyonggang@gmail.com>
Wed, 21 Dec 2022 16:46:34 +0000 (00:46 +0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Feb 2023 04:00:17 +0000 (04:00 +0000)
Because the place that called util_iround are always ensured
that INT_MIN <= f <= INT_MAX

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19978>

src/gallium/drivers/virgl/ci/traces-virgl.yml
src/util/u_math.h

index 9d942d2..8c0d980 100644 (file)
@@ -36,7 +36,7 @@ traces:
       checksum: aef0b32ce99a3b25d35304ca08032833
   gputest/plot3d-v2.trace:
     gl-virgl:
-      checksum: 817a36e53edccdf946061315596e9cdd
+      checksum: 96f9fdf530e6041a4f56762b8378f22e
   gputest/tessmark-v2.trace:
     gl-virgl:
       label: [skip, slow]
index 23116ce..bb639f4 100644 (file)
@@ -155,27 +155,12 @@ util_ifloor(float f)
 
 /**
  * Round float to nearest int.
+ * the range of f should be [INT_MIN, INT_MAX]
  */
 static inline int
 util_iround(float f)
 {
-#if DETECT_CC_GCC && DETECT_ARCH_X86
-   int r;
-   __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
-   return r;
-#elif DETECT_CC_MSVC && DETECT_ARCH_X86
-   int r;
-   _asm {
-      fld f
-      fistp r
-   }
-   return r;
-#else
-   if (f >= 0.0f)
-      return (int) (f + 0.5f);
-   else
-      return (int) (f - 0.5f);
-#endif
+   return (int)lrintf(f);
 }