diff --git a/loopy/statistics.py b/loopy/statistics.py index 7b728993164cc23d03154ee7ac2ad5629429ab30..57a8a83b55896b06ff322efe7d19e07c0121667d 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()