nir: Correctly constant fold fsign(NaN) and fsign(-0)
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 18 Feb 2020 20:34:15 +0000 (12:34 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 5 Jan 2021 02:07:09 +0000 (02:07 +0000)
commit71961c73a94ceca9dbeb8718acbe2c3c7a7ee717
treeaf7b8e8ae43ca5ec606ee67621691d47734fd4b7
parentfe3c5182775b935b6fb8e75b9a94de9561349870
nir: Correctly constant fold fsign(NaN) and fsign(-0)

GLSL and SPIR-V GLSL.std.450 don't have any requirements for fsign(NaN),
and both only require that FSign(-0.0) == 0.0.  OpenCL, on the other
hand, requires sign(-0.0) be exactly -0.0.  It also requires that
sign(NaN) be exactly 0.0.

In practice, this change is difficult to test.  Our GLSL frontend
already constant folds sign(NaN) to 0.0 before even getting to NIR.  As
far as I can tell, glslang does the same.  I don't have a good way to
run an OpenCL SPIR-V test.  Maybe SPIR-V GLSL.std.450 assembly?

No shader-db or fossil-db changes on any Intel platform.

Acked-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6358>
src/compiler/nir/nir_opcodes.py