Skip to content

Commit

Permalink
fix[next][dace]: Avoid bool cast in branch condition expressions (#1707)
Browse files Browse the repository at this point in the history
Casting the condition expression on an inter-state edge to `bool`
prevented dead-state elimination in the SDFG in case the expression was
specialized to True/False.
  • Loading branch information
edopao authored Oct 24, 2024
1 parent c1106fc commit 2927eba
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ def translate_if(

# expect true branch as second argument
true_state = sdfg.add_state(state.label + "_true_branch")
sdfg.add_edge(cond_state, true_state, dace.InterstateEdge(condition=f"bool({if_stmt})"))
sdfg.add_edge(cond_state, true_state, dace.InterstateEdge(condition=f"{if_stmt}"))
sdfg.add_edge(true_state, state, dace.InterstateEdge())

# and false branch as third argument
false_state = sdfg.add_state(state.label + "_false_branch")
sdfg.add_edge(cond_state, false_state, dace.InterstateEdge(condition=(f"not bool({if_stmt})")))
sdfg.add_edge(cond_state, false_state, dace.InterstateEdge(condition=(f"not ({if_stmt})")))
sdfg.add_edge(false_state, state, dace.InterstateEdge())

true_br_args = sdfg_builder.visit(
Expand Down

0 comments on commit 2927eba

Please sign in to comment.