In MSL output, avoid undefined behavior due to unbounded loops by adding an unpredictable, never-actually-taken break to the bottom of each loop body, rather than adding an unpredictable, never-actually-taken branch over each loop.
This will probably have more of a performance impact, because it affects each iteration of the loop, but unlike branching over the loop, which leaves infinite loops (and thus undefined behavior) in the output, this actually ensures that no loop presented to Metal is unbounded, so that there is no undefined behavior present that the optimizer could use to make unwelcome inferences.
In MSL output, avoid undefined behavior due to unbounded loops by adding an unpredictable, never-actually-taken
break
to the bottom of each loop body, rather than adding an unpredictable, never-actually-taken branch over each loop.This will probably have more of a performance impact, because it affects each iteration of the loop, but unlike branching over the loop, which leaves infinite loops (and thus undefined behavior) in the output, this actually ensures that no loop presented to Metal is unbounded, so that there is no undefined behavior present that the optimizer could use to make unwelcome inferences.
Fixes #6528.