blob: dba1d3953d3d462de639499405339ecd6eba1f8d (
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
69
70
71
72
73
74
75
76
77
78
79
|
//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target spirv -O0 -g3
RWStructuredBuffer<int> outputBuffer;
// This tests the following use cases:
// Inline single block function in multiple places.
// Inline single block function into multi-block function(This also covers multiple blocks with a phi node.)
// Inline single block function in multiple places in the same function.
// Inline multi-block function into another function
// Inline multi-block function multiple times
// Recursive inlining use case.
[ForceInline]
int calculateAdjustment(int value)
{
return value * 3 / 2;
}
[ForceInline]
int inlineMultipleBasicBlocks(int value)
{
int result = 0;
result = value * 2;
result = calculateAdjustment(result);
// Add another branch to create more basic blocks
if (result > 20)
{
result = result + 25;
}
else
{
result = result + 50;
}
result = value * 4;
result = calculateAdjustment(result);
// Add another branch to create more basic blocks
if (result < 20)
{
result = result + 10;
}
result = value * 10;
result = calculateAdjustment(result);
if (result < 250)
{
result = result + 100;
}
return result;
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int i = dispatchThreadID.x;
// Call the forceinline function
int result1 = inlineMultipleBasicBlocks(16);
int result2 = inlineMultipleBasicBlocks(22);
int result3 = calculateAdjustment(2);
outputBuffer[i] = result1 + result2 + result3;
}
// CHECK-COUNT-3: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugFunction %{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}} %uint_{{[0-9]+}} %uint_{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}} %uint_{{[0-9]+}} %uint_{{[0-9]+}}
// CHECK-NOT: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugFunction %{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}} %uint_{{[0-9]+}} %uint_{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}} %uint_{{[0-9]+}} %uint_{{[0-9]+}}
// TODO: Actual count is 6. But the pattern matcher complains to match.
// CHECK-COUNT-5: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugInlinedAt %uint_{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}}
// CHECK-NOT: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugInlinedAt %uint_{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}}
// CHECK-COUNT-27: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugScope %{{[0-9]+}} %{{[0-9]+}}
// CHECK-NOT: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugScope %{{[0-9]+}} %{{[0-9]+}}
|