Message170940
| Author |
vstinner |
| Recipients |
amaury.forgeotdarc, asvetlov, eric.smith, mark.dickinson, meador.inge, pitrou, rhettinger, sdaoden, serhiy.storchaka, stutzbach, vstinner, xuanji |
| Date |
2012年09月22日.00:41:57 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1348274519.79.0.306436521145.issue10044@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
If I understood correctly, the optimization proposed by Antoine was somehow rejected because _PyLong_IS_SMALL_INT() may be optimized "incorrectly".
If a compiler "miscompiles" this macro, can't we disable this optimization on this specific compiler, instead of missing an interesting optimization on all compilers? I bet that no compiler will do insane optimization on such test.
Where in CPython source code do we use directly references to small_ints? The common case is to write PyLong_FromLong(0). Can compiler call PyLong_FromLong() to detect that the result is part of the small_ints array? Or that it is not part of small_ints?
The corner case is very unlikely to me.
--
I tested Antoine's patch with GCC 4.6 and CFLAGS="-O3 -flto" (-flto: standard link-time optimizer): the test suite pass. I don't see any magic optimization here, sorry.
--
"fwiw I've always found this helpful for undefined behavior: http://blog.regehr.org/archives/213 and, just as it says "x+1 > x" will be optimized to a nop, by the same logic "v >= &array[0] && v < &array[array_len]" will also be optimized to a nop."
"x+1 > x" and "v >= &array[0]" are not the same checks. In the first test, x is used in both parts. I don't understand. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年09月22日 00:42:00 | vstinner | set | recipients:
+ vstinner, rhettinger, amaury.forgeotdarc, mark.dickinson, pitrou, eric.smith, stutzbach, asvetlov, meador.inge, xuanji, sdaoden, serhiy.storchaka |
| 2012年09月22日 00:41:59 | vstinner | set | messageid: <1348274519.79.0.306436521145.issue10044@psf.upfronthosting.co.za> |
| 2012年09月22日 00:41:59 | vstinner | link | issue10044 messages |
| 2012年09月22日 00:41:57 | vstinner | create |
|