summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Rath <Nikolaus@rath.org>2016-02-29 08:38:04 -0800
committerNikolaus Rath <Nikolaus@rath.org>2016-02-29 08:54:33 -0800
commit9c100bce6e68a382d3a43e62d4ad06ecadd1d865 (patch)
treed419165863fbb2b1d60d4fe0a6a4759ec18f9707
parent6e8b60bbeafb5d14d973d1a2c94f36875c2132f9 (diff)
downloadcython-9c100bce6e68a382d3a43e62d4ad06ecadd1d865.tar.gz
__Pyx_PyInt_TrueDivideObjC: switch comparison order
The current order results in compiler warnings on 32 bit machines, e.g. src/llfuse.c: In function '__Pyx_PyInt_TrueDivideObjC': src/llfuse.c:43980:17: warning: left shift count >= width of type if (8 * sizeof(long) <= 53 || (__Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) || likely(labs(a) <= (1L << 53))) { Switching the order so that the left shift is closer to the sizeof test avoids the warning, presumably because it makes it easier for the compiler to see that the left shift is only executed on 64 bit. Thanks to Christian Neukirchen for doing most of the work!
-rw-r--r--Cython/Utility/Optimize.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Cython/Utility/Optimize.c b/Cython/Utility/Optimize.c
index 431134d59..c7d3a0c86 100644
--- a/Cython/Utility/Optimize.c
+++ b/Cython/Utility/Optimize.c
@@ -659,7 +659,8 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO
x = a % b;
x += ((x != 0) & ((x ^ b) < 0)) * b;
{{elif op == 'TrueDivide'}}
- if (8 * sizeof(long) <= 53 || (__Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) || likely(labs({{ival}}) <= (1L << 53))) {
+ if ((8 * sizeof(long) <= 53 || likely(labs({{ival}}) <= (1L << 53)))
+ || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
return PyFloat_FromDouble((double)a / (double)b);
}
return PyLong_Type.tp_as_number->nb_{{slot_name}}(op1, op2);