blob: 3bfd795a83225146e3d60766cda1aef662ce8d68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
int test1(uint p)
{
int a, b;
if (p > 1)
{
a = 1;
b = 2;
}
else
{
a = 2;
b = 3;
}
// b is not used and should not interfere the result of a.
return a;
}
int test2(uint p)
{
int a, b;
if (p > 1)
{
a = 1;
b = 2;
}
else
{
a = 2;
b = 3;
}
// a is not used and should not interfere the result of b.
return b;
}
int test3(uint p)
{
int a = 1;
int b = 5;
if (p > 0) a = 2;
if (p > 0) b = 3;
// a and b are now register allocated.
// The first block of the loop will have IRParams in the form of (a, b)
for (int i = 0; i <= p + 2; i++)
{
let tmp = a;
a = b;
b = tmp;
// The branch back to the loop header will have phi args: (b, a)
// Phi-elmination must handle this case of concurrent assignment correctly.
}
return a - b; // should be 4 when p == 0.
}
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
let rs1 = test1(dispatchThreadID.x) + test2(dispatchThreadID.x);
outputBuffer[0] = rs1;
outputBuffer[1] = test3(0);
}
|