summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Rath <Nikolaus@rath.org>2016-02-29 08:38:04 -0800
committerStefan Behnel <stefan_ml@behnel.de>2016-03-24 14:27:03 +0100
commit201feed25881488eb10a96b0dba7ea858434dddb (patch)
tree25fa9de18e9a049e7a46d7b68776aee37bfc4c0f
parentb07167c974673d19730022e9c589b9c0b8216e88 (diff)
downloadcython-201feed25881488eb10a96b0dba7ea858434dddb.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 e1468bf3a..70e8050e6 100644
--- a/Cython/Utility/Optimize.c
+++ b/Cython/Utility/Optimize.c
@@ -661,7 +661,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);