diff --git a/loopy/codegen/instruction.py b/loopy/codegen/instruction.py
index 323951a63a7f9c370bfd0a357ae585a6bd1b336b..d3a7ae42c078fc39c5844e3cb8047900ae347dc1 100644
--- a/loopy/codegen/instruction.py
+++ b/loopy/codegen/instruction.py
@@ -232,7 +232,7 @@ def generate_c_instruction_code(kernel, insn, codegen_state):
     from pymbolic.primitives import Variable
     for name, iname_expr in insn.iname_exprs:
         if (isinstance(iname_expr, Variable)
-                and name not in ecm.var_subst_map):
+                and name not in codegen_state.var_subst_map):
             # No need, the bare symbol will work
             continue