intel/compiler: Fix rebuilding the CFG in fs_combine_constants

When building the CFG the instructions are taken of the list in
fs_visitor and added to the lists inside each block.  The single
"exec_node" in the instruction is used for those memberships.

In the case the pass rebuilt the CFG, it had no instructions, so
calculate_cfg() had nothing to work with.  For now fix the bug by
pulling all the instructions back to the original list.

We can do better here, but punting until upcoming work on
CFG itself.

Issue found in an unpublished CTS test.  Small reproduction in our
unit tests now enabled.

Fixes: 65237f8bbc ("intel/fs: Don't add MOV instructions to DO blocks in combine constants")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27131>
This commit is contained in:
Caio Oliveira 2024-01-17 17:21:57 -08:00 committed by Marge Bot
parent e9bfdcf576
commit 4dbf9181cd
2 changed files with 11 additions and 1 deletions

View file

@ -1834,6 +1834,16 @@ fs_visitor::opt_combine_constants()
}
if (rebuild_cfg) {
/* When the CFG is initially built, the instructions are removed from
* the list of instructions stored in fs_visitor -- the same exec_node
* is used for membership in that list and in a block list. So we need
* to pull them back before rebuilding the CFG.
*/
assert(exec_list_length(&instructions) == 0);
foreach_block(block, cfg) {
exec_list_append(&instructions, &block->instructions);
}
delete cfg;
cfg = NULL;
calculate_cfg();

View file

@ -98,7 +98,7 @@ TEST_F(FSCombineConstantsTest, Simple)
ASSERT_EQ(bblock_end(block)->opcode, BRW_OPCODE_SEL);
}
TEST_F(FSCombineConstantsTest, DISABLED_DoContainingDo)
TEST_F(FSCombineConstantsTest, DoContainingDo)
{
fs_builder bld = make_builder(shader);