rsx/fp/cfg: Add unit test for special cond inversion

This commit is contained in:
kd-11 2026-03-19 03:26:58 +03:00 committed by kd-11
parent 3c68c36fa0
commit ddd226f0ea

View file

@ -228,4 +228,27 @@ namespace rsx::assembler
ASSERT_EQ(graph.blocks.size(), 1);
EXPECT_EQ(graph.blocks.front().instructions.size(), 1);
}
TEST(CFG, FpToCFG_EmptyIFWithELSE)
{
auto ir = FPIR::from_source(
"IF.LT;" // Empty branch
"ELSE;" // With real ELSE
" MOV R1, R2;" // Content. Should execute if branch cond fails (IF.GE)
"ENDIF;"
"MOV R0, R1;" // False merge block.
);
RSXFragmentProgram program{};
auto bytecode = ir.compile();
program.data = bytecode.data();
FlowGraph graph = deconstruct_fragment_program(program);
ASSERT_EQ(graph.blocks.size(), 3);
ASSERT_EQ(graph.blocks.front().instructions.size(), 1);
EXPECT_EQ(SRC0{ .HEX = graph.blocks.front().instructions[0].bytecode[1] }.exec_if_lt, 0);
EXPECT_EQ(SRC0{ .HEX = graph.blocks.front().instructions[0].bytecode[1] }.exec_if_gr, 1);
EXPECT_EQ(SRC0{ .HEX = graph.blocks.front().instructions[0].bytecode[1] }.exec_if_eq, 1);
}
}