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 <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
James Price 2022-11-02 18:01:31 +00:00 committed by Dawn LUCI CQ
parent c81f9dce07
commit fd9c3fe4bc
2 changed files with 38 additions and 5 deletions

View File

@ -1121,11 +1121,7 @@ class UniformityGraph {
v1_cf->AddEdge(v1); v1_cf->AddEdge(v1);
auto [cf2, v2] = ProcessExpression(v1_cf, b->rhs); auto [cf2, v2] = ProcessExpression(v1_cf, b->rhs);
return std::pair<Node*, Node*>(cf, v2);
if (sem_.Get(b)->Behaviors() == sem::Behaviors{sem::Behavior::kNext}) {
return std::pair<Node*, Node*>(cf, v2);
}
return std::pair<Node*, Node*>(cf2, v2);
} else { } else {
auto [cf1, v1] = ProcessExpression(cf, b->lhs); auto [cf1, v1] = ProcessExpression(cf, b->lhs);
auto [cf2, v2] = ProcessExpression(cf1, b->rhs); auto [cf2, v2] = ProcessExpression(cf1, b->rhs);

View File

@ -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<storage, read> 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<storage, read_write> 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) { TEST_F(UniformityAnalysisTest, ShortCircuiting_ReconvergeLHS) {
std::string src = R"( std::string src = R"(
@group(0) @binding(0) var<storage, read_write> non_uniform_global : i32; @group(0) @binding(0) var<storage, read_write> non_uniform_global : i32;