nir: Add an algebraic optimization for float->double->float
authorJesse Natalie <jenatali@microsoft.com>
Mon, 22 Jun 2020 15:12:54 +0000 (08:12 -0700)
committerDave Airlie <airlied@redhat.com>
Mon, 28 Dec 2020 23:07:24 +0000 (09:07 +1000)
As part of this series, it removes the need for float->double conversion,
just to be able to print a single float.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8254>

src/compiler/nir/nir_opt_algebraic.py

index 0cd50c3..aa55e20 100644 (file)
@@ -1065,6 +1065,10 @@ optimizations.extend([
    (('f2f32', ('i2fmp', 'a@32')), ('i2f32', a)),
    (('f2f32', ('u2fmp', 'a@32')), ('u2f32', a)),
 
+   # Conversions from float32 to float64 and back can be removed as long as
+   # it doesn't need to be precise, since the conversion may e.g. flush denorms
+   (('~f2f32', ('f2f64', 'a@32')), a),
+
    (('ffloor', 'a(is_integral)'), a),
    (('fceil', 'a(is_integral)'), a),
    (('ftrunc', 'a(is_integral)'), a),