From 0026eb8bafe7df20b283d2fd08d9754a28f20571 Mon Sep 17 00:00:00 2001
From: Tim Warburton <timwar@caam.rice.edu>
Date: Tue, 25 Oct 2011 19:35:56 -0500
Subject: [PATCH] Use loopy's own SubstitutionMapper (not pymbolic's
 substitute) in realize_cse().

---
 loopy/__init__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/loopy/__init__.py b/loopy/__init__.py
index a90e99ffd..5e36fc111 100644
--- a/loopy/__init__.py
+++ b/loopy/__init__.py
@@ -320,10 +320,13 @@ def realize_cse(kernel, cse_tag, dtype, duplicate_inames=[], parallel_inames=Non
                 var(iname) for iname in duplicate_inames
                 )]
 
-        from pymbolic import substitute
-        new_inner_expr = substitute(rec(expr.child), dict(
-            (old_iname, var(new_iname))
-            for old_iname, new_iname in zip(duplicate_inames, new_inames)))
+        from loopy.symbolic import SubstitutionMapper
+        from pymbolic.mapper.substitutor import make_subst_func
+        subst_map = SubstitutionMapper(make_subst_func(
+            dict(
+                (old_iname, var(new_iname))
+                for old_iname, new_iname in zip(duplicate_inames, new_inames))))
+        new_inner_expr = subst_map(rec(expr.child))
 
         # }}}
 
-- 
GitLab