Mesa (master): nir/algebraic: i2f(f2i()) -> trunc()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 15 00:54:16 UTC 2020


Module: Mesa
Branch: master
Commit: 6f394343b1f704f8b98a24add7f4106e72e2db7b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f394343b1f704f8b98a24add7f4106e72e2db7b

Author: Elie Tournier <tournier.elie at gmail.com>
Date:   Thu May 23 17:16:18 2019 +0100

nir/algebraic: i2f(f2i()) -> trunc()

total instructions in shared programs: 12840968 -> 12840784 (<.01%)
instructions in affected programs: 17886 -> 17702 (-1.03%)
helped: 77
HURT: 0

total cycles in shared programs: 302508917 -> 302505592 (<.01%)
cycles in affected programs: 249964 -> 246639 (-1.33%)
helped: 70
HURT: 7

Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/948>

---

 src/compiler/nir/nir_opt_algebraic.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index fbf0f694430..73056c3c35c 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -803,6 +803,11 @@ optimizations.extend([
    (('i2b', ('iabs', a)), ('i2b', a)),
    (('inot', ('f2b1', a)), ('feq', a, 0.0)),
 
+   # The C spec says, "If the value of the integral part cannot be represented
+   # by the integer type, the behavior is undefined."  "Undefined" can mean
+   # "the conversion doesn't happen at all."
+   (('~i2f32', ('f2i32', 'a at 32')), ('ftrunc', a)),
+
    # Ironically, mark these as imprecise because removing the conversions may
    # preserve more precision than doing the conversions (e.g.,
    # uint(float(0x81818181u)) == 0x81818200).



More information about the mesa-commit mailing list