From b6f58b4709c240c7dd17c59674e0f63d70af70e5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 2 Mar 2020 18:42:04 -0800 Subject: [PATCH] soft-fp64/fsat: Micro-optimize x < 0 test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Matt Turner Part-of: --- src/compiler/glsl/float64.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 363248c9f59..e7a7e7860fc 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -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 */)) -- 2.30.2