From 977eb925b7e9cb1a763c1e5563b2bc605b6476d6 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 13 Feb 2023 10:39:12 -0800 Subject: Eliminate `continue` to allow unrolling any loops. (#2645) Co-authored-by: Yong He --- tests/ir/loop-unroll-2.slang | 23 +++++++++++++++++++++++ tests/ir/loop-unroll-2.slang.expected.txt | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 tests/ir/loop-unroll-2.slang create mode 100644 tests/ir/loop-unroll-2.slang.expected.txt (limited to 'tests/ir') diff --git a/tests/ir/loop-unroll-2.slang b/tests/ir/loop-unroll-2.slang new file mode 100644 index 000000000..aff227432 --- /dev/null +++ b/tests/ir/loop-unroll-2.slang @@ -0,0 +1,23 @@ +//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 outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + int sum = 0; + [ForceUnroll] + for (int i = 0; i < 2; i++) + { + [ForceUnroll(2)] + for (int j = 1; j < 3; j++) + { + if (i == 1 && j == 1) + continue; + sum += (i+j); + } + } + outputBuffer[0] = sum; +} diff --git a/tests/ir/loop-unroll-2.slang.expected.txt b/tests/ir/loop-unroll-2.slang.expected.txt new file mode 100644 index 000000000..e20d75ba3 --- /dev/null +++ b/tests/ir/loop-unroll-2.slang.expected.txt @@ -0,0 +1,4 @@ +6 +0 +0 +0 -- cgit v1.2.3