From 5dd401e416e18fdfe904a66284b0cf56cf256ec7 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 31 May 2023 12:36:48 -0700 Subject: Fix div-by-zero error during sccp. (#2911) * Diagnose on div-by-zero during sccp. * fix --------- Co-authored-by: Yong He --- tests/diagnostics/sccp-div-by-zero.slang | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/diagnostics/sccp-div-by-zero.slang (limited to 'tests/diagnostics') diff --git a/tests/diagnostics/sccp-div-by-zero.slang b/tests/diagnostics/sccp-div-by-zero.slang new file mode 100644 index 000000000..b7c85fe10 --- /dev/null +++ b/tests/diagnostics/sccp-div-by-zero.slang @@ -0,0 +1,19 @@ +//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -profile cs_5_0 -target hlsl +RWStructuredBuffer outputBuffer; + +// CHECK: divide by zero +uint check() +{ + return 1 / int(b); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + uint a = check(); + uint b = check(); + + outputBuffer[tid] = a + b; +} \ No newline at end of file -- cgit v1.2.3