From fd9c3fe4bcedb2f1aed628c27fe6d38a768f2a89 Mon Sep 17 00:00:00 2001 From: James Price Date: Wed, 2 Nov 2022 18:01:31 +0000 Subject: [PATCH] tint/uniforimty: Remove short-circuit special-case Now that expressions can only ever have the `Next` behavior, short-circuiting operators will always reconverge. Change-Id: Ib9fe4c774191b8a304fa7f7a6eafdfa6c6e6f18a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108202 Kokoro: Kokoro Auto-Submit: James Price Reviewed-by: Ben Clayton Commit-Queue: James Price --- src/tint/resolver/uniformity.cc | 6 +---- src/tint/resolver/uniformity_test.cc | 37 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/tint/resolver/uniformity.cc b/src/tint/resolver/uniformity.cc index 831e49e0a3..d5ff80349b 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -1121,11 +1121,7 @@ class UniformityGraph { v1_cf->AddEdge(v1); auto [cf2, v2] = ProcessExpression(v1_cf, b->rhs); - - if (sem_.Get(b)->Behaviors() == sem::Behaviors{sem::Behavior::kNext}) { - return std::pair(cf, v2); - } - return std::pair(cf2, v2); + return std::pair(cf, v2); } else { auto [cf1, v1] = ProcessExpression(cf, b->lhs); auto [cf2, v2] = ProcessExpression(cf1, b->rhs); diff --git a/src/tint/resolver/uniformity_test.cc b/src/tint/resolver/uniformity_test.cc index faefb13d26..fbaeff93cf 100644 --- a/src/tint/resolver/uniformity_test.cc +++ b/src/tint/resolver/uniformity_test.cc @@ -6939,6 +6939,43 @@ test:5:11 note: reading from read_write storage buffer 'rw' may result in a non- )"); } +TEST_F(UniformityAnalysisTest, ShortCircuiting_UniformLHS) { + std::string src = R"( +@group(0) @binding(0) var uniform_global : i32; + +fn main() { + let b = (uniform_global == 0) && (dpdx(1.0) == 0.0); +} +)"; + + RunTest(src, true); +} + +TEST_F(UniformityAnalysisTest, ShortCircuiting_NonUniformLHS) { + std::string src = R"( +@group(0) @binding(0) var non_uniform_global : i32; + +fn main() { + let b = (non_uniform_global == 0) && (dpdx(1.0) == 0.0); +} +)"; + + RunTest(src, false); + EXPECT_EQ(error_, + R"(test:5:41 warning: 'dpdx' must only be called from uniform control flow + let b = (non_uniform_global == 0) && (dpdx(1.0) == 0.0); + ^^^^ + +test:5:37 note: control flow depends on non-uniform value + let b = (non_uniform_global == 0) && (dpdx(1.0) == 0.0); + ^^ + +test:5:12 note: reading from read_write storage buffer 'non_uniform_global' may result in a non-uniform value + let b = (non_uniform_global == 0) && (dpdx(1.0) == 0.0); + ^^^^^^^^^^^^^^^^^^ +)"); +} + TEST_F(UniformityAnalysisTest, ShortCircuiting_ReconvergeLHS) { std::string src = R"( @group(0) @binding(0) var non_uniform_global : i32;