From 64fc15a27906dca58fe396a485327a0de110d669 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Fri, 18 Sep 2020 16:16:14 -0400 Subject: [PATCH] Add unit test for a dead do-while loop. Ideally the optimizer should be able to detect and remove this loop. This CL establishes a baseline. Change-Id: I6aba0b52fe49552f170fca25d81c29c515044ef5 Bug: skia:10737 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317861 Commit-Queue: John Stiles Commit-Queue: Brian Osman Auto-Submit: John Stiles Reviewed-by: Brian Osman --- gn/sksl_tests.gni | 1 + tests/sksl/glsl/DeadDoWhileLoop.sksl | 5 +++++ tests/sksl/glsl/golden/DeadDoWhileLoop.glsl | 7 +++++++ 3 files changed, 13 insertions(+) create mode 100644 tests/sksl/glsl/DeadDoWhileLoop.sksl create mode 100644 tests/sksl/glsl/golden/DeadDoWhileLoop.glsl diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni index 3f33c250aa..0a0d1a10e9 100644 --- a/gn/sksl_tests.gni +++ b/gn/sksl_tests.gni @@ -123,6 +123,7 @@ sksl_glsl_tests_sources = [ "$_tests/sksl/glsl/ConstVariableComparison.sksl", "$_tests/sksl/glsl/ConstantIf.sksl", "$_tests/sksl/glsl/Control.sksl", + "$_tests/sksl/glsl/DeadDoWhileLoop.sksl", "$_tests/sksl/glsl/DeadLoopVariable.sksl", "$_tests/sksl/glsl/DependentInitializers.sksl", "$_tests/sksl/glsl/DerivativesUnused.sksl", diff --git a/tests/sksl/glsl/DeadDoWhileLoop.sksl b/tests/sksl/glsl/DeadDoWhileLoop.sksl new file mode 100644 index 0000000000..47e8b85265 --- /dev/null +++ b/tests/sksl/glsl/DeadDoWhileLoop.sksl @@ -0,0 +1,5 @@ +void main() { + do { + sk_FragColor = half4(1); + } while (false); +} diff --git a/tests/sksl/glsl/golden/DeadDoWhileLoop.glsl b/tests/sksl/glsl/golden/DeadDoWhileLoop.glsl new file mode 100644 index 0000000000..3c0463c8ed --- /dev/null +++ b/tests/sksl/glsl/golden/DeadDoWhileLoop.glsl @@ -0,0 +1,7 @@ + +out vec4 sk_FragColor; +void main() { + do { + sk_FragColor = vec4(1.0); + } while (false); +}