From 8991cf13ad2a5bb205ea8d2fe4b041858030e58a Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sat, 1 Jul 2017 13:52:22 +0200
Subject: [PATCH] Fix grid factor computation in get_unused_hw_axes_factor

---
 loopy/statistics.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/loopy/statistics.py b/loopy/statistics.py
index dc938ef70..2df2cb53c 100755
--- a/loopy/statistics.py
+++ b/loopy/statistics.py
@@ -1045,13 +1045,13 @@ def get_unused_hw_axes_factor(knl, insn, disregard_local_axes, space=None):
         result = 1
         for iaxis, size in enumerate(size):
             if iaxis not in used_axes:
-                result = result * size
+                if not isinstance(size, int):
+                    if space is not None:
+                        size = size.align_params(space)
 
-        if not isinstance(result, int):
-            if space is not None:
-                result = result.align_params(space)
+                    size = isl.PwQPolynomial.from_pw_aff(size)
 
-            result = isl.PwQPolynomial.from_pw_aff(result)
+                result = result * size
 
         return result
 
-- 
GitLab