soft-fp64/fsat: Micro-optimize x < 0 test
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 3 Mar 2020 02:42:04 +0000 (18:42 -0800)
committerMarge Bot <eric+marge@anholt.net>
Wed, 18 Mar 2020 20:36:29 +0000 (20:36 +0000)
Results on the 308 shaders extracted from the fp64 portion of the OpenGL
CTS:

Tiger Lake and Ice Lake had similar results. (Tiger Lake shown)
total instructions in shared programs: 841647 -> 841590 (<.01%)
instructions in affected programs: 122014 -> 121957 (-0.05%)
helped: 7
HURT: 0
helped stats (abs) min: 3 max: 12 x̄: 8.14 x̃: 9
helped stats (rel) min: 0.04% max: 0.07% x̄: 0.05% x̃: 0.04%
95% mean confidence interval for instructions value: -11.23 -5.06
95% mean confidence interval for instructions %-change: -0.06% -0.03%
Instructions are helped.

total cycles in shared programs: 6926904 -> 6926828 (<.01%)
cycles in affected programs: 1038645 -> 1038569 (<.01%)
helped: 7
HURT: 0
helped stats (abs) min: 4 max: 16 x̄: 10.86 x̃: 12
helped stats (rel) min: <.01% max: 0.01% x̄: <.01% x̃: <.01%
95% mean confidence interval for cycles value: -14.97 -6.74
95% mean confidence interval for cycles %-change: -0.01% <.01%
Cycles are helped.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>

src/compiler/glsl/float64.glsl

index 363248c9f593d85cc587e39feaa4ba1f29dff945..e7a7e7860fce3cbc5d1a6e3477458dd7cdfd4b45 100644 (file)
@@ -258,8 +258,10 @@ __fge64(uint64_t a, uint64_t b)
 uint64_t
 __fsat64(uint64_t __a)
 {
+   uvec2 a = unpackUint2x32(__a);
+
    /* fsat(NaN) should be zero. */
-   if (__is_nan(__a) || __flt64_nonnan(__a, 0ul))
+   if (__is_nan(__a) || int(a.y) < 0)
       return 0ul;
 
    if (!__flt64_nonnan(__a, 0x3FF0000000000000ul /* 1.0 */))