nir: Add optimization for doing removing f16/f32 conversions
authorHyunjun Ko <zzoon@igalia.com>
Mon, 5 Aug 2019 06:36:38 +0000 (06:36 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Feb 2020 17:24:13 +0000 (17:24 +0000)
commit9e8466a866cbfb4c6745d85e9371b43827d16c8d
tree0e92c5c0022c00dd2cf7dc2994c5df915c21806e
parent6ee375f68dabc0dd9d6d9f919b797231aad19eab
nir: Add optimization for doing removing f16/f32 conversions

This eliminates conversions between f16 and f32 where possible. We can
always remove an upcast followed by a down cast, that is:

  f2f16 ( f2f32 (a) )  ->  a
  f2fmp ( f2f32 (a) )  ->  a

In the other direction, f2f16 loses precision and can't be undone by a
f2f32.  However, by definition it's always safe to elminate f2fmp:

  f2f32 ( f2fmp (a) )  ->  a

v2. [Neil Roberts (nroberts@igalia.com)]

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3822>
src/compiler/nir/nir_opt_algebraic.py