From 3f779013423b5472e1da939dab1304e9998cfc47 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Mon, 22 Jun 2020 08:12:54 -0700 Subject: [PATCH] nir: Add an algebraic optimization for float->double->float 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 Reviewed-by: Alyssa Rosenzweig Reviewed-by: Dave Airlie Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 0cd50c38d78..aa55e203ffd 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -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),