From b8a175df48f5482bf8f2da2cd3ce3ac3cb23a7df Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Tue, 8 Nov 2011 17:24:34 -0500
Subject: [PATCH] Add remove_cses().

---
 loopy/__init__.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/loopy/__init__.py b/loopy/__init__.py
index 9e6f16fa6..a5f1cb632 100644
--- a/loopy/__init__.py
+++ b/loopy/__init__.py
@@ -453,6 +453,20 @@ def add_prefetch(kernel, var_name, fetch_dims=[], uni_template=None,
 
 # }}}
 
+def remove_cses(kernel):
+    from loopy.symbolic import CSECallbackMapper
+
+    def map_cse(expr, rec):
+        return expr.child
+
+    new_insns = []
+    for insn in kernel.instructions:
+        new_insns.append(
+                insn.copy(
+                    expression=CSECallbackMapper(map_cse)(insn.expression)))
+
+    return kernel.copy(instructions=new_insns)
+
 
 
 
-- 
GitLab