I want to nitpick this wording a bit. I think when I wrote the original code I was only thinking of nodes produced inside of a loop.
That makes sense. @giomasce said that this bug was probably a result of implementing copy propagation, since, after that, nodes outside the loop could be read inside the loop.
That's still what I think of when I see this comment (or commit message), and I still think that doesn't actually make conceptual sense. Rather, what does make sense, and what this patch addresses is the case where a node produced before the loop is used inside the loop.
How about: "vkd3d-shader/hlsl: Extend the liveness of nodes produced outside loops."
```c /* Compute the earliest and latest liveness for each variable. In the case that * a variable is accessed inside of a loop, we promote its liveness to extend * to at least the range of the entire loop. We also do this for nodes produced * before the loop, so that their temp register is protected from being * overriden during the whole loop. */ ```
Now I think we could extend the liveness only if `instr->index < loop_start`.