From 70be98f17a1b8c66a92daac2a3d4eeb084bbc954 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 3 Mar 2020 19:44:13 -0800 Subject: [PATCH] soft-fp64/fadd: Massively split the live range of zFrac0 and zFrac1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The main purpose of this commit is to prepare for "soft-fp64/fadd: Move common code out of both branches of an if-statement". 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: 822766 -> 817327 (-0.66%) instructions in affected programs: 760943 -> 755504 (-0.71%) helped: 74 HURT: 0 helped stats (abs) min: 8 max: 515 x̄: 73.50 x̃: 51 helped stats (rel) min: 0.58% max: 1.10% x̄: 0.77% x̃: 0.73% 95% mean confidence interval for instructions value: -91.17 -55.83 95% mean confidence interval for instructions %-change: -0.81% -0.74% Instructions are helped. total cycles in shared programs: 6816791 -> 6822826 (0.09%) cycles in affected programs: 6384809 -> 6390844 (0.09%) helped: 0 HURT: 74 HURT stats (abs) min: 6 max: 1179 x̄: 81.55 x̃: 50 HURT stats (rel) min: 0.02% max: 0.17% x̄: 0.09% x̃: 0.09% 95% mean confidence interval for cycles value: 48.99 114.12 95% mean confidence interval for cycles %-change: 0.09% 0.10% Cycles are HURT. Reviewed-by: Matt Turner Part-of: --- src/compiler/glsl/float64.glsl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 46cae0a4cdb..6208a37757e 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -676,11 +676,11 @@ __fadd64(uint64_t a, uint64_t b) uint bFracHi = __extractFloat64FracHi(b); int aExp = __extractFloat64Exp(a); int bExp = __extractFloat64Exp(b); - uint zFrac0 = 0u; - uint zFrac1 = 0u; int expDiff = aExp - bExp; if (aSign == bSign) { - uint zFrac2 = 0u; + uint zFrac0; + uint zFrac1; + uint zFrac2; int zExp; bool orig_exp_diff_is_zero = (expDiff == 0); @@ -736,6 +736,9 @@ __fadd64(uint64_t a, uint64_t b) __shortShift64Left(aFracHi, aFracLo, 10, aFracHi, aFracLo); __shortShift64Left(bFracHi, bFracLo, 10, bFracHi, bFracLo); if (0 < expDiff) { + uint zFrac0; + uint zFrac1; + if (aExp == 0x7FF) { bool propagate = (aFracHi | aFracLo) != 0u; return mix(a, __propagateFloat64NaN(a, b), propagate); @@ -750,6 +753,9 @@ __fadd64(uint64_t a, uint64_t b) return __normalizeRoundAndPackFloat64(aSign, zExp - 10, zFrac0, zFrac1); } if (expDiff < 0) { + uint zFrac0; + uint zFrac1; + if (bExp == 0x7FF) { bool propagate = (bFracHi | bFracLo) != 0u; return mix(__packFloat64(aSign ^ 0x80000000u, 0x7ff, 0u, 0u), __propagateFloat64NaN(a, b), propagate); @@ -770,6 +776,9 @@ __fadd64(uint64_t a, uint64_t b) } bExp = mix(bExp, 1, aExp == 0); aExp = mix(aExp, 1, aExp == 0); + + uint zFrac0 = 0; + uint zFrac1 = 0; bool zexp_normal = false; uint sign_of_difference = 0; if (bFracHi < aFracHi) { -- 2.30.2