diff --git a/loopy/context_matching.py b/loopy/context_matching.py
index 6a428144ea04aa6f1c5491993a6cc19d19818f55..76ef818f3cbd3b81c60da6c73f5ee4fe27d63989 100644
--- a/loopy/context_matching.py
+++ b/loopy/context_matching.py
@@ -148,7 +148,10 @@ class StackWildcardMatch(StackMatchBase):
 
         n = len(stack)
 
-        for i in xrange(n):
+        if self.up_match(stack):
+            return True
+
+        for i in xrange(1, n):
             if self.up_match(stack[:-i]):
                 return True