Skip to content

Commit 1f5682f

Browse files
authored
gh-129987: Disable GCC SLP autovectorization for the interpreter loop on x86-64 (#132295)
The SLP autovectorizer can cause poor code generation for opcode dispatch, negating any benefit we get from vectorization elsewhere in the interpreter loop.
1 parent 67ded6a commit 1f5682f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Python/ceval.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,18 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
948948
#include "generated_cases.c.h"
949949
#endif
950950

951-
PyObject* _Py_HOT_FUNCTION
951+
#if (defined(__GNUC__) && !defined(__clang__)) && defined(__x86_64__)
952+
/*
953+
* gh-129987: The SLP autovectorizer can cause poor code generation for opcode
954+
* dispatch, negating any benefit we get from vectorization elsewhere in the
955+
* interpreter loop.
956+
*/
957+
#define DONT_SLP_VECTORIZE __attribute__((optimize ("no-tree-slp-vectorize")))
958+
#else
959+
#define DONT_SLP_VECTORIZE
960+
#endif
961+
962+
PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE
952963
_PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
953964
{
954965
_Py_EnsureTstateNotNULL(tstate);

0 commit comments

Comments
 (0)