Skip to content

intel/fs: Avoid generating useless UNDEFs for every SSA def

Kenneth Graunke requested to merge kwg/mesa:brw-less-undef into main

intel/fs: Avoid generating useless UNDEFs for every SSA def

Emitting UNDEF is only necessary when the instructions we generate to produce the NIR def are considered partial writes. By adding a simple check (adapted from fs_inst::is_partial_write()), we can avoid creating loads of unnecessary UNDEFs that we have to clean up later.

Our first dead code elimination pass does get rid of them pretty quickly, but this should save memory and time during our first split_virtual_grfs and dead_code_elimination passes.

This generates roughly 30% fewer instructions at the beginning.

Improves compilation time of shaders:

  • Rise of the Tomb Raider: -3.51563% +/- 0.103951% (n=7)
  • Borderlands 3: -3.64422% +/- 0.300951% (n=7).

Merge request reports