diff --git a/dace/transformation/interstate/if_extraction.py b/dace/transformation/interstate/if_extraction.py index 55f37ef123..71a886e61f 100644 --- a/dace/transformation/interstate/if_extraction.py +++ b/dace/transformation/interstate/if_extraction.py @@ -74,10 +74,15 @@ def can_be_applied(self, graph, expr_index, sdfg, permissive=False): for e in sdfg.predecessor_state_transitions(start_state): available_symbols |= e.data.new_symbols(sdfg, available_symbols).keys() - # check if edges can be moved out (used symbols can be computed in the outer scope) + # check if used symbols can be computed in the outer scope if not if_symbols.issubset(available_symbols): return False + # check if symbols are not written in the state containing the nested sdfg + _, wset = sdfg.parent.read_and_write_sets() + if len(if_symbols.intersection(wset)) != 0: + return False + return True