Revert "nir/algebraic: Convert some f2u to f2i"
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 6 Aug 2021 21:20:25 +0000 (14:20 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Aug 2021 22:16:13 +0000 (22:16 +0000)
commit84d2e537890acea01da2795e5dd3bac1319635f5
tree8a0d49519c1686254f3f67628bbb264b9e271630
parent3ba66ebbc8207a24282b3aab57a2d691d10199f9
Revert "nir/algebraic: Convert some f2u to f2i"

Per https://gitlab.freedesktop.org/mesa/mesa/-/issues/5178#note_1019666,
the assumption fundamental to this optimization is false.  Section
2.4.1 (Float to Integer) of Ivy Bridge PRMs describes the situation.
The wording of the section is somewhat confusing (because it doesn't
clearly delineate between signed and unsigned integers), but the last
two rows of the table make it clear that F->UD conversion clamps
negative float values to 0.

All other hardware mentioned in that thread seems to behave the same
way.

The real problem is that, with hardware that behaves in this ways,
converting f2u(2147483648.0) to f2i(2147483648.0) changes the bit pattern
that would be produced from 0x80000000 to 0x7fffffff.

This reverts commit ad059202583e8c86bbccf0d65c5ce35bc4ab20f1.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12297>
src/compiler/nir/nir_opt_algebraic.py