[spirv-reader] Classify kSwitchBreak edges
These used to be classified as kToMerge Bug: tint:3 Change-Id: I63fb286c371582676e5943a3082c0614b9c8d5d0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21081 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
920bdcd0aa
commit
ab56088ae7
|
@ -1052,9 +1052,13 @@ bool FunctionEmitter::ClassifyCFGEdges() {
|
||||||
const bool src_is_loop_header = header_info.continue_for_header != 0;
|
const bool src_is_loop_header = header_info.continue_for_header != 0;
|
||||||
const bool src_is_continue_header =
|
const bool src_is_continue_header =
|
||||||
header_info.header_for_continue != 0;
|
header_info.header_for_continue != 0;
|
||||||
edge_kind = (src_is_loop_header || src_is_continue_header)
|
if (src_is_loop_header || src_is_continue_header) {
|
||||||
? EdgeKind::kLoopBreak
|
edge_kind = EdgeKind::kLoopBreak;
|
||||||
: EdgeKind::kToMerge;
|
} else if (src_construct.kind == Construct::kSwitchSelection) {
|
||||||
|
edge_kind = EdgeKind::kSwitchBreak;
|
||||||
|
} else {
|
||||||
|
edge_kind = EdgeKind::kToMerge;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto* loop_or_continue_construct =
|
const auto* loop_or_continue_construct =
|
||||||
src_construct.enclosing_loop_or_continue;
|
src_construct.enclosing_loop_or_continue;
|
||||||
|
|
|
@ -4612,7 +4612,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromIfThenElse) {
|
||||||
EXPECT_EQ(bi50->succ_edge[99], EdgeKind::kToMerge);
|
EXPECT_EQ(bi50->succ_edge[99], EdgeKind::kToMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseDirect) {
|
TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchCaseDirect) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -4634,10 +4634,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseDirect) {
|
||||||
auto* bi = fe.GetBlockInfo(10);
|
auto* bi = fe.GetBlockInfo(10);
|
||||||
ASSERT_NE(bi, nullptr);
|
ASSERT_NE(bi, nullptr);
|
||||||
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
||||||
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kToMerge);
|
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kSwitchBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseBody) {
|
TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchCaseBody) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -4659,10 +4659,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseBody) {
|
||||||
auto* bi = fe.GetBlockInfo(20);
|
auto* bi = fe.GetBlockInfo(20);
|
||||||
ASSERT_NE(bi, nullptr);
|
ASSERT_NE(bi, nullptr);
|
||||||
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
||||||
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kToMerge);
|
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kSwitchBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchDefaultBody) {
|
TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchDefaultBody) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -4687,10 +4687,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchDefaultBody) {
|
||||||
auto* bi = fe.GetBlockInfo(30);
|
auto* bi = fe.GetBlockInfo(30);
|
||||||
ASSERT_NE(bi, nullptr);
|
ASSERT_NE(bi, nullptr);
|
||||||
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
||||||
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kToMerge);
|
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kSwitchBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchDefaultIsMerge) {
|
TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchDefaultIsMerge) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -4712,7 +4712,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchDefaultIsMerge) {
|
||||||
auto* bi = fe.GetBlockInfo(10);
|
auto* bi = fe.GetBlockInfo(10);
|
||||||
ASSERT_NE(bi, nullptr);
|
ASSERT_NE(bi, nullptr);
|
||||||
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
EXPECT_EQ(bi->succ_edge.count(99), 1);
|
||||||
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kToMerge);
|
EXPECT_EQ(bi->succ_edge[99], EdgeKind::kSwitchBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ClassifyCFGEdges_LoopBreak_FromLoopBody) {
|
TEST_F(SpvParserTest, ClassifyCFGEdges_LoopBreak_FromLoopBody) {
|
||||||
|
|
Loading…
Reference in New Issue