Skip to content

nir/dead_cf: Do not remove loops with loads that can't be reordered

Caio Oliveira requested to merge cmarcelo/mesa:r/nir-dead-cf-not-drop-loads into main

If a loop is followed by a barrier, the ordering between a load inside the loop and other memory operations after the barrier may have to be preserved depending on the type of memory involved. This is relevant when the memory is writeable by other invocations. In such case, it is not valid to completely eliminate the loop.

This commit doesn't attempt to precisely catch the barrier case, as analysis could become too complex. It simply assumes it can't drop the loops that contain certain types of loads unless those are known to be safe to reorder (via the access flag).

Fixes: #4475 (closed)

Merge request reports