Open sklam opened 1 year ago
Here is the reproducer and image:
"0":
jt: ["1", "2"]
"1":
jt: ["3", "3"]
"2":
jt: ["4"]
"3":
jt: ["2"]
"4":
jt: ["3", "5"]
"5":
jt: ["4", "6"]
"6":
jt: []
Using the patch:
diff --git i/numba_rvsdg/core/transformations.py w/numba_rvsdg/core/transformations.py
index b3d59811b6..a630ef45cb 100644
--- i/numba_rvsdg/core/transformations.py
+++ w/numba_rvsdg/core/transformations.py
@@ -143,7 +143,7 @@ def loop_restructure_helper(scfg: SCFG, loop: Set[Label]):
# matters in this case.
new_jt[new_jt.index(jt)] = synth_assign
# If the target is the loop_head
- elif jt in headers and label not in doms[jt]:
+ elif jt in headers and (label not in doms[jt] or label == jt):
# Create the assignment and record it
synth_assign = SynthenticAssignment(str(scfg.clg.new_index()))
new_blocks.add(synth_assign)
Actually allows the loop restructuring to continue, but then it produces:
Incidentally, the SCCs for the case are:
{ControlLabel(index='3'), ControlLabel(index='2'), ControlLabel(index='5'), ControlLabel(index='4')}
But I think I need to apply "loop restruturing" manually to know what to expect. Python doesn't have a goto, I don't think the code is equipped to handle a backedge that ends up in the middle of the loop somewhere.
I am changing the mockasm code so no branches have the same jump target on both side.
However, the assert len(diff) == 1
can trip on group like:
YAML:
"mock_block_0":
jt: ["mock_block_5", "mock_block_8"]
"mock_block_2":
jt: ["mock_block_3", "mock_block_4"]
"mock_block_3":
jt: ["mock_block_4"]
"mock_block_4":
jt: ["mock_block_5"]
"mock_block_5":
jt: ["mock_block_3", "mock_block_6"]
"mock_block_6":
jt: ["mock_block_8", "mock_block_9"]
"mock_block_7":
jt: ["mock_block_2", "mock_block_11"]
"mock_block_8":
jt: ["mock_block_9"]
"mock_block_9":
jt: ["mock_block_7", "mock_block_2"]
"mock_block_11":
jt: []
From
DEBUGGRAPH=1 pytest numba_rvsdg/tests/test_mock_asm.py::test_mock_scfg_fuzzer_case146
in #42CFG:
Traceback: