Directive for overflow folding.
authorRobert Bradshaw <robertwb@gmail.com>
Fri, 28 Dec 2012 20:25:12 +0000 (12:25 -0800)
committerRobert Bradshaw <robertwb@gmail.com>
Fri, 28 Dec 2012 20:25:12 +0000 (12:25 -0800)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Optimize.py
Cython/Compiler/Options.py

index 5238c0f..b9e9887 100755 (executable)
@@ -8048,6 +8048,7 @@ class NumBinopNode(BinopNode):
                     and not self.operand2.has_constant_result()):
                 self.operand1, self.operand2 = self.operand2, self.operand1
             self.overflow_check = True
+            self.overflow_fold = env.directives['overflowcheck.fold']
             self.func = self.type.overflow_check_binop(
                 self.overflow_op_names[self.operator],
                 env,
index d8d02ab..f744a0b 100644 (file)
@@ -3265,7 +3265,7 @@ class ConsolidateOverflowCheck(Visitor.CythonTransform):
         return node
     
     def visit_NumBinopNode(self, node):
-        if node.overflow_check:
+        if node.overflow_check and node.overflow_fold:
             top_level_overflow = self.overflow_bit_node is None
             if top_level_overflow:
                 self.overflow_bit_node = node
index 91f48ca..a29c889 100644 (file)
@@ -82,6 +82,7 @@ directive_defaults = {
     'cdivision': False, # was True before 0.12
     'cdivision_warnings': False,
     'overflowcheck': False,
+    'overflowcheck.fold': True,
     'always_allow_keywords': False,
     'allow_none_for_extension_args': True,
     'wraparound' : True,