From 2927eba14ae68f40db927eeb4510fb97b6540141 Mon Sep 17 00:00:00 2001 From: edopao Date: Thu, 24 Oct 2024 16:00:22 +0200 Subject: [PATCH] fix[next][dace]: Avoid bool cast in branch condition expressions (#1707) 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. --- .../runners/dace_fieldview/gtir_builtin_translators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_builtin_translators.py b/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_builtin_translators.py index 277d8a0cd8..5e3a220caa 100644 --- a/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_builtin_translators.py +++ b/src/gt4py/next/program_processors/runners/dace_fieldview/gtir_builtin_translators.py @@ -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(