freedreno/ir3: Add new ir3 pass to fold out fp16 conversions
authorHyunjun Ko <zzoon@igalia.com>
Fri, 11 Oct 2019 08:38:36 +0000 (08:38 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Feb 2020 17:24:13 +0000 (17:24 +0000)
commit6ee375f68dabc0dd9d6d9f919b797231aad19eab
treedffb5ecd9eb8e36fa917c156c64db3d73fec5099
parent125f867d3dc32c7269c17d3426e35a0dcd5aadc4
freedreno/ir3: Add new ir3 pass to fold out fp16 conversions

This pass tries to fold f2f16 conversion into alu instructions.
This will be useful to help reduce the number of instructions once
mesa starts supporting precision lowering.  For example:

  add.f r0.w, r0.w, c0.x
  cov.f32f16 hr2.x, r0.w

to

  add.f hr2.x, r0.w, c0.x

Additionally this pass also tries to fold f2f16 conversion into load_input
instruction:

  bary.f r0.x, 3, r0.w
  cov.f32f16 hr0.x, r0.x

to

  bary.f hr1.x, 3, r0.x

v2: Edit to not fold OPC_MAX_F and OPC_MIN_F, since that's not valid.

v3: Add OPC_ABSNEG_F to the blacklist as well.

v4: Don't remove dead cov instructions, DCE will do that later; don't
iterate through sources when a cov only has one; remove special
handling of IR3_REG_ARRAY and IR3_REG_RELATIV.

v5: Handle folding into u32.u32 movs of floats correctly, don't bail
out on IR3_REG_RELATIV or IR3_REG_ARRAY movs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3822>
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_cf.c [new file with mode: 0644]
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/meson.build