nir/opt_if: also merge break statements with ones after the branch
authorDaniel Schürmann <daniel@schuermann.dev>
Fri, 30 Oct 2020 21:56:52 +0000 (22:56 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 13 Jan 2022 02:30:32 +0000 (02:30 +0000)
commit79a987ad2a1e0c7c2a6f9803459de3ace993cb55
tree934964f164162b7fa227e5d9f5e73c4d4700bb11
parentdad609d1521e1627c15bc7b7a852a20d510729cc
nir/opt_if: also merge break statements with ones after the branch

 This optimizations turns

     loop {
        ...
        if (cond1) {
           if (cond2) {
              do_work_1();
              break;
           } else {
              do_work_2();
           }
           do_work_3();
           break;
        } else {
           ...
        }
     }

 into:

     loop {
        ...
        if (cond1) {
           if (cond2) {
              do_work_1();
           } else {
              do_work_2();
              do_work_3();
           }
           break;
        } else {
           ...
        }
     }

As this optimizations moves code into the NIF statement,
it re-iterates on the branch legs in case of success.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7587>
src/compiler/nir/nir_opt_if.c
src/gallium/drivers/d3d12/ci/d3d12-quick_shader.txt