Fix bug in batched codegen of compref when the index is varying.
The llvm_load_value was left to defaulted to uniform load, which we can't store into a varying/wide result. Fixed similar bug in getmessage, and added check for spline knotcount to be uniform (although varying support could be added).
This bug exposed a missed optimization in BatchedAnalysis where a early out (return) needs to change the loop conditional to be varying to support masking. However no check was being done to see if the loop control existed higher in the callstack. So now the execution scope tracks loop nesting depth to see if the current function is really in a loop or not. This allows the loop control flow to remain uniform (avoiding masking and more complex control flow).
Tests
Added nestloop-reg to testsuite to reproduce bug and verify its fixed.
[x] I have updated the documentation, if applicable.
[x] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
[x] My code follows the prevailing code style of this project. If I haven't
already run clang-format v17 before submitting, I definitely will look at
the CI test that runs clang-format and fix anything that it highlights as
being nonconforming.
Description
Fix bug in batched codegen of compref when the index is varying. The llvm_load_value was left to defaulted to uniform load, which we can't store into a varying/wide result. Fixed similar bug in getmessage, and added check for spline knotcount to be uniform (although varying support could be added).
This bug exposed a missed optimization in BatchedAnalysis where a early out (return) needs to change the loop conditional to be varying to support masking. However no check was being done to see if the loop control existed higher in the callstack. So now the execution scope tracks loop nesting depth to see if the current function is really in a loop or not. This allows the loop control flow to remain uniform (avoiding masking and more complex control flow).
Tests
Added nestloop-reg to testsuite to reproduce bug and verify its fixed.
Checklist: