nir: Fix breakage of foreach_list_typed_safe assumptions in loop unrolling
foreach_list_typed_safe
works with assumption that even if current node
becomes invalid, the next will be still valid.
However process_loops broke this assumption, because during iteration when immediate child is unrolled - not only current node could be removed but also the one after it.
This doesn't cause issues now but it will cause issues when undefined
behaviour in foreach*
macros is fixed.
The fix is done in this way to avoid unrolling both outer and inner loop in one pass.
Last run on Intel CI (https://mesa-ci.01.org/global_logic/builds/250/group/63a9f0ea7bb98050796b649e85481845) had some issues probably not related to this commit, but I'll resend it again later.
Ci passes: https://mesa-ci.01.org/global_logic/builds/251/group/63a9f0ea7bb98050796b649e85481845
Also see !4129 (merged) for the fix in macros.