diff options
| author | Yong He <yonghe@outlook.com> | 2023-06-26 15:18:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-26 15:18:06 -0700 |
| commit | 4c9e4de4b68f2612a39e8783e9da89605ecf54e0 (patch) | |
| tree | 83a8efcc45d3d67d07f18caad49a9469252bf509 /tests/bugs/mutating | |
| parent | 4eef0424a657e19f51f2734ba0199b69ee7354bd (diff) | |
Fix DCE on mutable calls in a loop. (#2943)
* Fix DCE on mutable calls in a loop.
* More accurate in-loop test.
* code review fixes.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/bugs/mutating')
| -rw-r--r-- | tests/bugs/mutating/mutating-call-in-loop-dce.slang | 39 | ||||
| -rw-r--r-- | tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt | 2 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/bugs/mutating/mutating-call-in-loop-dce.slang b/tests/bugs/mutating/mutating-call-in-loop-dce.slang new file mode 100644 index 000000000..372cb61b0 --- /dev/null +++ b/tests/bugs/mutating/mutating-call-in-loop-dce.slang @@ -0,0 +1,39 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type + +// Confirm that a SideEffectFree mutable method does not get DCE'd when +// it is called from within a loop. + +struct C +{ + int a; + [mutating] + int add() + { + a++; + return a; + } + [mutating] + void init() + { + a = 0; + } +} +int doSomething(C d) +{ + int rs = 0; + for (int i = 0; i < 10; i++) + rs = d.add(); + return rs; +} + +//TEST_INPUT:ubuffer(data=[0], stride=4):out, name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + C c; + c.init(); + outputBuffer[tid] = doSomething(c); +}
\ No newline at end of file diff --git a/tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt b/tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt new file mode 100644 index 000000000..2c29f3f9e --- /dev/null +++ b/tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt @@ -0,0 +1,2 @@ +type: int32_t +10 |
