diff options
| author | jarcherNV <jarcher@nvidia.com> | 2025-04-11 14:51:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-11 21:51:48 +0000 |
| commit | 61a6c211b1587a7b9ed6a24ae1ba6fe0600c80d8 (patch) | |
| tree | b67322ca56975223cc2eb897acc29155928128fd /tests | |
| parent | 88a180ba0aa57b2d0fb4956005db2ea73dc73420 (diff) | |
Add flag to hoist instructions (#6740)
This fixes issue #6654
Only hoist instructions that are optimized by prepareFuncForForwardDiff.
Add flag hoistLoopInvariantInsts to IRSimplificationOptions and set this
to true only if called from prepareFuncForForwardDiff, then only hoist
if the flag is set. Additionally, do not hoist loops if they only have a
single trivial iteration.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/spirv/forceinline-nohoist.slang | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/spirv/forceinline-nohoist.slang b/tests/spirv/forceinline-nohoist.slang new file mode 100644 index 000000000..54db2838f --- /dev/null +++ b/tests/spirv/forceinline-nohoist.slang @@ -0,0 +1,32 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main
+
+// Verify that the call to dot is after the conditional branch.
+
+// CHECK: OpBranchConditional
+// CHECK: OpDot
+
+[ForceInline]
+float test(bool x, float3 a, float3 b) {
+ float result = 0;
+ if(x) {
+ result = dot(a, b);
+ }
+ return result;
+}
+
+float caller(uniform bool x, uniform float3 a, uniform float3 b) {
+ return test(x, a, b);
+}
+
+RWStructuredBuffer<float> output;
+
+uniform bool branchCheck;
+uniform float3 uniformA;
+uniform float3 uniformB;
+
+[numthreads(1,1,1)]
+[shader("compute")]
+void main()
+{
+ output[0] = caller(branchCheck, uniformA, uniformB);
+}
|
