yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeSSA Register Allocation improvements. (#2857)c571bcb02

master
1.0 KiB49 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain -line-directive-mode none
2
3
4RWStructuredBuffer<float> outputBuffer;
5
6int test1()
7{
8    float t = 0;
9    for (int i = 0; i < 5; i++)
10    {
11        if (i < 3)
12            t = t + 1;
13        else
14            t = t + 2;
15        // we should coalesce the phi after the `if` the and phi of the `for` loop.
16    }
17    outputBuffer[0] = t;
18    return 0;
19}
20// CHECK: int test1{{[_0-9]*}}()
21// CHECK-NOT: float t_1
22// CHECK: return
23
24int test2()
25{
26    float v = 0;
27    for (int i = 0; i < 5; i++)
28    {
29        float ov = v;
30        if (i < 3)
31            v = v + 1;
32        else
33            v = v + 2;
34        // use of ot here means we can't coalesce the phis of the `if` and the `for` loop.
35        outputBuffer[1] = ov;
36    }
37    outputBuffer[0] = v;
38    return 0;
39}
40// CHECK: int test2{{[_0-9]*}}()
41// CHECK: float v_1
42// CHECK: return
43
44[numthreads(1, 1, 1)]
45void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
46{
47    test1();
48    test2();
49}