mesa/src/compiler
Ian Romanick bf2eb3e0ee soft-fp64: Split a block that was missing a cast on a comparison
This function has code like:

   if (0x7FD <= zExp) {
      if ((0x7FD < zExp) ||
         ((zExp == 0x7FD) &&
            (0x001FFFFFu == zFrac0 && 0xFFFFFFFFu == zFrac1) &&
               increment)) {
         ...
	 return ...;
      }
      if (zExp < 0) {

I saw that, and I thought, "Uh... what?  Dead code?"  I thought it was a
bit fishy, so I grabbed the Berkeley SoftFloat Library 3e code, and
there is similar code in softfloat_roundPackToF64
(source/s_roundPackToF64.c), but it has an extra (uint16_t) cast in the
first comparison.  This is basicially a shortcut for

   if (zExp < 0 || zExp >= 0x7FD) {

So, having the nesting kind of makes sense. On a CPU, nesting the flow
control can be an optimization.  On a GPU, it's just fail.  Split the
block so that we don't need the uint16_t cast magic.

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: 683638 -> 658127 (-3.73%)
instructions in affected programs: 666839 -> 641328 (-3.83%)
helped: 92
HURT: 0
helped stats (abs) min: 26 max: 2456 x̄: 277.29 x̃: 144
helped stats (rel) min: 3.21% max: 4.22% x̄: 3.79% x̃: 3.90%
95% mean confidence interval for instructions value: -345.84 -208.75
95% mean confidence interval for instructions %-change: -3.86% -3.73%
Instructions are helped.

total cycles in shared programs: 5458858 -> 5344600 (-2.09%)
cycles in affected programs: 5360114 -> 5245856 (-2.13%)
helped: 92
HURT: 0
helped stats (abs) min: 126 max: 10300 x̄: 1241.93 x̃: 655
helped stats (rel) min: 1.71% max: 2.37% x̄: 2.12% x̃: 2.17%
95% mean confidence interval for cycles value: -1539.93 -943.94
95% mean confidence interval for cycles %-change: -2.16% -2.08%
Cycles are helped.

Fixes: f111d72596 ("glsl: Add "built-in" functions to do add(fp64, fp64)")
Reviewed-by: Matt Turner <mattst88@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4142>
2020-03-18 20:36:29 +00:00
..
glsl soft-fp64: Split a block that was missing a cast on a comparison 2020-03-18 20:36:29 +00:00
nir soft-fp64/flt: Perform checks in a different order 2020-03-18 20:36:29 +00:00
spirv Revert "spirv: Use a simpler and more correct implementaiton of tanh()" 2020-03-05 15:23:31 +00:00
Android.glsl.gen.mk mesa: android: Remove unnecessary dependency tracking rules 2019-05-06 11:29:25 +00:00
Android.glsl.mk android: glsl: build shader cache sources 2017-02-20 16:30:37 +00:00
Android.mk
Android.nir.gen.mk nir: Add missing dependency in Android.nir.gen.mk 2019-08-19 09:53:18 +03:00
Android.nir.mk android: fix libmesa_nir build 2017-07-21 08:47:56 +03:00
builtin_type_macros.h glsl_types: vec8/vec16 support 2018-03-25 10:42:54 -04:00
glsl_types.cpp spirv_to_nir: Reuse glsl_sampler_dim_coordinate_components(). 2020-02-24 18:25:02 +00:00
glsl_types.h glsl: Add type queries for fp16+float and fp16+float+double 2020-03-09 16:31:08 +00:00
Makefile.sources nir: Add pass to combine adjacent scoped memory barriers 2020-03-12 19:21:36 +00:00
meson.build meson: drop unused inc_nir 2019-10-07 21:49:40 +01:00
nir_types.cpp nir: fix compilation warning on glsl_get_internal_ifc_packing 2020-03-09 09:43:49 +00:00
nir_types.h nir: fix compilation warning on glsl_get_internal_ifc_packing 2020-03-09 09:43:49 +00:00
SConscript spirv: Fix building with SCons 2018-03-30 14:33:03 -06:00
SConscript.glsl compiler: move build definition of pp_standalone_scaffolding.c 2019-11-21 16:07:08 +11:00
SConscript.nir nir: mako all the intrinsics 2018-03-27 08:36:37 -04:00
SConscript.spirv spirv: Fix building with SCons 2018-03-30 14:33:03 -06:00
shader_enums.c compiler: add new SYSTEM_VALUE_BARYCENTRIC_* 2020-01-29 09:49:50 +00:00
shader_enums.h compiler: add new SYSTEM_VALUE_BARYCENTRIC_* 2020-01-29 09:49:50 +00:00
shader_info.h nir/glsl: gather bitmask of images used by program 2020-03-16 10:34:21 +00:00