[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:
David Neto 2020-05-06 18:32:38 +00:00
parent 920bdcd0aa
commit ab56088ae7
2 changed files with 15 additions and 11 deletions

View File

@ -1052,9 +1052,13 @@ bool FunctionEmitter::ClassifyCFGEdges() {
const bool src_is_loop_header = header_info.continue_for_header != 0;
const bool src_is_continue_header =
header_info.header_for_continue != 0;
edge_kind = (src_is_loop_header || src_is_continue_header)
? EdgeKind::kLoopBreak
: EdgeKind::kToMerge;
if (src_is_loop_header || src_is_continue_header) {
edge_kind = EdgeKind::kLoopBreak;
} else if (src_construct.kind == Construct::kSwitchSelection) {
edge_kind = EdgeKind::kSwitchBreak;
} else {
edge_kind = EdgeKind::kToMerge;
}
} else {
const auto* loop_or_continue_construct =
src_construct.enclosing_loop_or_continue;

View File

@ -4612,7 +4612,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromIfThenElse) {
EXPECT_EQ(bi50->succ_edge[99], EdgeKind::kToMerge);
}
TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseDirect) {
TEST_F(SpvParserTest, ClassifyCFGEdges_SwitchBreak_FromSwitchCaseDirect) {
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@ -4634,10 +4634,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseDirect) {
auto* bi = fe.GetBlockInfo(10);
ASSERT_NE(bi, nullptr);
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"(
%100 = OpFunction %void None %voidfn
@ -4659,10 +4659,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchCaseBody) {
auto* bi = fe.GetBlockInfo(20);
ASSERT_NE(bi, nullptr);
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"(
%100 = OpFunction %void None %voidfn
@ -4687,10 +4687,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchDefaultBody) {
auto* bi = fe.GetBlockInfo(30);
ASSERT_NE(bi, nullptr);
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"(
%100 = OpFunction %void None %voidfn
@ -4712,7 +4712,7 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_ToMerge_FromSwitchDefaultIsMerge) {
auto* bi = fe.GetBlockInfo(10);
ASSERT_NE(bi, nullptr);
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) {