diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2025-07-02 14:18:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 21:18:21 +0000 |
| commit | 3e1dd65adff0873e0385040c5c0a003eda83de3b (patch) | |
| tree | 8e8c3902d3e96e2e39346d4a306d04771f3ca121 /tests | |
| parent | 54a5d7f0056b4a846c790e7e019b9b5e74f76a98 (diff) | |
[HLSL, SPIRV_1_3] Hoist OpSelect returning a composite into `if`/`else` (#7594)
* emit var and hoist out OpSelect if Composite
* cleanup comment
* address review
check for version in spv context
use phi node instead of using var
move inst's using a list (not in-place modification)
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/op-select-return-composite.slang | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/bugs/op-select-return-composite.slang b/tests/bugs/op-select-return-composite.slang new file mode 100644 index 000000000..eb453d457 --- /dev/null +++ b/tests/bugs/op-select-return-composite.slang @@ -0,0 +1,34 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-d3d12 -output-using-type -use-dxil +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -output-using-type -profile spirv_1_3 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +struct CompositeType +{ + __init(int dataIn) + { + data1 = dataIn; + data2 = dataIn; + } + int data1; + float data2; +} + +[numthreads(1,1,1)] +void computeMain(){ + + CompositeType composite = CompositeType(-1); + if (outputBuffer[0] == 0) + { + composite = outputBuffer[1] > -1 ? CompositeType(1) : CompositeType(-1); + } + outputBuffer[2] = composite.data1; + outputBuffer[3] = (int)composite.data2; +} + +//BUF: 0 +//BUF: 0 +//BUF: 1 +//BUF: 1 |
