diff options
author | Ian Romanick <[email protected]> | 2020-03-04 12:23:13 -0800 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-18 20:36:29 +0000 |
commit | da3fa01891ec41ced3cbe2b63e8e5c8252e6e7ba (patch) | |
tree | 37bfa18eb6c6c84cebf189205248f50ea60881b5 | |
parent | 3c9ff97215b0c13c82f460dcc59cb61f6b02d78c (diff) |
soft-fp64/fadd: Rename aFrac and bFrac variables
Exchanging aFracHi / bFracHi and aFracLo / bFracLo should not affect the
result of the later call to __add64.
The main purpose of this commit is to prepare for "soft-fp64/fadd: Move
common code out of both branches of an if-statement".
v2: Fix a typo in a comment. Noticed by Matt.
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: 812094 -> 818246 (0.76%)
instructions in affected programs: 750271 -> 756423 (0.82%)
helped: 0
HURT: 74
HURT stats (abs) min: 7 max: 520 x̄: 83.14 x̃: 59
HURT stats (rel) min: 0.52% max: 1.48% x̄: 0.89% x̃: 0.84%
95% mean confidence interval for instructions value: 63.96 102.31
95% mean confidence interval for instructions %-change: 0.83% 0.95%
Instructions are HURT.
total cycles in shared programs: 6797157 -> 6816686 (0.29%)
cycles in affected programs: 6365175 -> 6384704 (0.31%)
helped: 0
HURT: 74
HURT stats (abs) min: 16 max: 1690 x̄: 263.91 x̃: 181
HURT stats (rel) min: 0.14% max: 0.68% x̄: 0.32% x̃: 0.27%
95% mean confidence interval for cycles value: 199.74 328.07
95% mean confidence interval for cycles %-change: 0.29% 0.36%
Cycles are HURT.
total spills in shared programs: 703 -> 705 (0.28%)
spills in affected programs: 703 -> 705 (0.28%)
helped: 0
HURT: 1
total fills in shared programs: 1499 -> 1501 (0.13%)
fills in affected programs: 1499 -> 1501 (0.13%)
helped: 0
HURT: 1
Reviewed-by: Matt Turner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
-rw-r--r-- | src/compiler/glsl/float64.glsl | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl index 40cc84439fb..cdecfdb8dbb 100644 --- a/src/compiler/glsl/float64.glsl +++ b/src/compiler/glsl/float64.glsl @@ -661,6 +661,17 @@ __propagateFloat64NaN(uint64_t __a, uint64_t __b) #endif } +/* If a shader is in the soft-fp64 path, it almost certainly has register + * pressure problems. Choose a method to exchange two values that does not + * require a temporary. + */ +#define EXCHANGE(a, b) \ + do { \ + a ^= b; \ + b ^= a; \ + a ^= b; \ + } while (false) + /* Returns the result of adding the double-precision floating-point values * `a' and `b'. The operation is performed according to the IEEE Standard for * Floating-Point Arithmetic. @@ -709,15 +720,19 @@ __fadd64(uint64_t a, uint64_t b) bFracHi, bFracLo, 0u, expDiff, bFracHi, bFracLo, zFrac2); zExp = aExp; } else { - if (bExp == 0x7FF) { - bool propagate = (bFracHi | bFracLo) != 0u; + EXCHANGE(aFracHi, bFracHi); + EXCHANGE(aFracLo, bFracLo); + EXCHANGE(aExp, bExp); + + if (aExp == 0x7FF) { + bool propagate = (aFracHi | aFracLo) != 0u; return mix(__packFloat64(aSign, 0x7ff, 0u, 0u), __propagateFloat64NaN(a, b), propagate); } - expDiff = mix(expDiff, expDiff + 1, aExp == 0); - aFracHi = mix(aFracHi | 0x00100000u, aFracHi, aExp == 0); + expDiff = mix(expDiff, expDiff + 1, bExp == 0); + bFracHi = mix(bFracHi | 0x00100000u, bFracHi, bExp == 0); __shift64ExtraRightJamming( - aFracHi, aFracLo, 0u, - expDiff, aFracHi, aFracLo, zFrac2); - zExp = bExp; + bFracHi, bFracLo, 0u, - expDiff, bFracHi, bFracLo, zFrac2); + zExp = aExp; } aFracHi |= 0x00100000u; |