From 339c46f9095dbe30ff4194e3c61ffdd08d9c9537 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 21 Sep 2015 18:20:19 -0500 Subject: [PATCH] Bring in @jdsteve's fix for not counting multiplication by (-1) --- loopy/statistics.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/loopy/statistics.py b/loopy/statistics.py index 7b7289931..57a8a83b5 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -129,18 +129,16 @@ class ExpressionOpCounter(CombineMapper): def map_product(self, expr): from pymbolic.primitives import is_zero if expr.children: - return ToCountMap( - {self.type_inf(expr): len(expr.children)-1} - ) + sum( - self.rec(child) - for child in expr.children - - # Do not count '(-1)* ' (as produced by - # subtraction in pymbolic): Assume this - # gets implemented as a sign flip or - # as subtraction. (Confirmed to be true on - # at least Nvidia 352.30.) - if not is_zero(child - 1)) + return sum(ToCountMap({self.type_inf(expr): 1}) + self.rec(child) + for child in expr.children + # Do not count '(-1)* ' (as produced by + # subtraction in pymbolic): Assume this + # gets implemented as a sign flip or + # as subtraction. (Confirmed to be true on + # at least Nvidia 352.30.) + if not is_zero(child + 1)) + \ + ToCountMap({self.type_inf(expr): -1}) + else: return ToCountMap() -- GitLab