diff --git a/loopy/transform/subst.py b/loopy/transform/subst.py
index 9ce1f9c5420e8dbbc0d3a94b6c465e443c5f109d..e599c902227faf8d1292ece2307d097bc8fd7c19 100644
--- a/loopy/transform/subst.py
+++ b/loopy/transform/subst.py
@@ -349,7 +349,7 @@ def assignment_to_subst(kernel, lhs_name, extra_arguments=(), within=None,
 
     usage_to_definition = {}
 
-    for insn in kernel.instructions:
+    for insn in dep_kernel.instructions:
         if lhs_name not in insn.read_dependency_names():
             continue