amd/llvm: Fix divergent descriptor indexing. (v3)
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 2 Dec 2019 08:53:37 +0000 (09:53 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 12 Mar 2020 16:12:02 +0000 (16:12 +0000)
commitb83c9aca4a5fd02d920c90c1799137fed52dc1d9
tree7b588a57adae280e9a2fcf68346d755f475aa695
parentba88e951871ae1df5ba567c8f4071dddbe50e286
amd/llvm: Fix divergent descriptor indexing. (v3)

There are multiple LLVM passes that very much move the
intrinsic using the descriptor outside of the loop, defeating
the entire point of creating the loop.

Defeat the optimizer by  splitting the break into a separate
if-statement and putting an optimization barrier on the bool
in between.

v2: Move from a callback based system to begin/end loop.
    This does not make it significantly less intrusive but
    is a bit nicer with all the extra struct and callback
    stubs.
v3: Deal with non-divergent values in divergent path.

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2160
Fixes: 028ce527395 "radv: Add non-uniform indexing lowering."
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4109>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4109>
src/amd/llvm/ac_nir_to_llvm.c
src/amd/vulkan/radv_pipeline.c