nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: GridTools/gt4py
Pull request #2028 (2025-05-12 09:25:10)

fix[next]: Enable more constant folding transformations in dead code elimination


Patch:
diff --git a/src/gt4py/next/iterator/transforms/dead_code_elimination.py b/src/gt4py/next/iterator/transforms/dead_code_elimination.py
index 213f37ca..6ea2739b 100644
--- a/src/gt4py/next/iterator/transforms/dead_code_elimination.py
+++ b/src/gt4py/next/iterator/transforms/dead_code_elimination.py
@@ -49,9 +49,7 @@ def dead_code_elimination(
 
     # remove the unreachable if branches
     # e.g. `if_(True, val1, val2)` -> `val1`
-    program = ConstantFolding.apply(
-        program, enabled_transformations=ConstantFolding.Transformation.FOLD_IF
-    )  # type: ignore[assignment]  # always an itir.Program
+    program = ConstantFolding.apply(program)  # type: ignore[assignment]  # always an itir.Program
 
     # inline again since after constant folding some expressions might not be referenced anymore,
     # e.g. `let field = as_fieldop(...) in val1 end` -> `val1`.


Test patch:
diff --git a/tests/next_tests/unit_tests/iterator_tests/transforms_tests/test_dead_code_elimination.py b/tests/next_tests/unit_tests/iterator_tests/transforms_tests/test_dead_code_elimination.py
index f294bb12..b5786d89 100644
--- a/tests/next_tests/unit_tests/iterator_tests/transforms_tests/test_dead_code_elimination.py
+++ b/tests/next_tests/unit_tests/iterator_tests/transforms_tests/test_dead_code_elimination.py
@@ -41,7 +41,10 @@ def program_factory(expr: itir.Expr) -> itir.Program:
 
 @pytest.mark.parametrize(
     "input,expected",
-    [(im.let("val", "inp1")(im.if_(True, "val", "inp2")), im.ref("inp1"))],
+    [
+        (im.let("val", "inp1")(im.if_(True, "val", "inp2")), im.ref("inp1")),
+        (im.let("val", "inp1")(im.if_(im.and_(True, True), "val", "inp2")), im.ref("inp1")),
+    ],
 )
 def test_let_constant_foldable_if(input, expected):
     input_program = program_factory(input)