Module: Mesa
Branch: staging/23.0
Commit: b94117ec59441314ae1d4a1cf68b47d92c383558
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b94117ec59441314ae1d4a1cf68b47d92c383558

Author: Isabella Basso <[email protected]>
Date:   Fri Mar 10 17:20:10 2023 -0300

nir/algebraic: make patterns for float conversion lowerings imprecise

As noted on [1], lowering patterns of the form
floatS -> floatB -> floatS ==> floatS
cannot require precision since this may cause flush denorming.

[1] 3f779013 ("nir: Add an algebraic optimization for float->double->float")

Fixes: b86305bb ("nir/algebraic: collapse conversion opcodes (many patterns)")
Acked-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Georg Lehmann <[email protected]>
Signed-off-by: Isabella Basso <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20965>
(cherry picked from commit a553d3cd2985b604f92ef02568b2164880d1fe7f)

Conflicts:
        src/compiler/nir/nir_opt_algebraic.py

---

 .pick_status.json                     | 2 +-
 src/compiler/nir/nir_opt_algebraic.py | 6 +-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 16debd8d482..6bcb3a4a2b2 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -7069,7 +7069,7 @@
         "description": "nir/algebraic: make patterns for float conversion 
lowerings imprecise",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "b86305bb5734fdd0511d227b646328ef03c80197"
     },
diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 104bda19cee..1d3858b0ef6 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -982,7 +982,7 @@ for s in [16, 32, 64]:
             optimizations.extend([
                # S = smaller, B = bigger
                # typeS -> typeB -> typeS ==> identity
-               (('f2f{}'.format(s), ('f2f{}'.format(B), 'a@{}'.format(s))), a),
+               (('~f2f{}'.format(s), ('f2f{}'.format(B), 'a@{}'.format(s))), 
a),
                (('i2i{}'.format(s), ('i2i{}'.format(B), 'a@{}'.format(s))), a),
                (('u2u{}'.format(s), ('u2u{}'.format(B), 'a@{}'.format(s))), a),
 
@@ -1482,10 +1482,6 @@ 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),

Reply via email to