-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
8 changed files
with
189 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: int32_t | ||
10 |