agx: Detect conditional breaks
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 29 Aug 2023 21:01:54 +0000 (17:01 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Sep 2023 18:50:34 +0000 (18:50 +0000)
commit6e0ae2c31654e44a9f6de9aedc4980aff4bb4860
tree7b6ab24ba37eac10750ed78af8fbc21da4a9b87f
parenta009f39fca7064766d9e1d91bf8dc76c4ab4dc17
agx: Detect conditional breaks

Search for code like

   if ... {
      break
   }

and replace with a break_if pseudo-instruction for optimized handling, since the
break_if lowering is better than the original code.

   total instructions in shared programs: 1764596 -> 1764350 (-0.01%)
   instructions in affected programs: 24540 -> 24294 (-1.00%)
   helped: 78
   HURT: 0
   Instructions are helped.

   total bytes in shared programs: 11611196 -> 11610212 (<.01%)
   bytes in affected programs: 166458 -> 165474 (-0.59%)
   helped: 78
   HURT: 0
   Bytes are helped.

shader-db probably understates the benefit here, since this optimizes the body
of loops.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25052>
src/asahi/compiler/agx_compile.c
src/asahi/compiler/agx_compiler.h
src/asahi/compiler/agx_opt_break_if.c [new file with mode: 0644]
src/asahi/compiler/meson.build