From 45cd78643d8a874fb30047ea2448c979638d8ed8 Mon Sep 17 00:00:00 2001 From: Matt Page Date: Tue, 8 Apr 2025 15:07:19 -0700 Subject: [PATCH] Disable GCC SLP autovectorization for the interpreter loop on x86-64 --- Python/ceval.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Python/ceval.c b/Python/ceval.c index a59b2b7a16866d..47d068edac2743 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -948,7 +948,18 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch) #include "generated_cases.c.h" #endif -PyObject* _Py_HOT_FUNCTION +#if (defined(__GNUC__) && !defined(__clang__)) && defined(__x86_64__) +/* + * gh-129987: The SLP autovectorizer can cause poor code generation for opcode + * dispatch, negating any benefit we get from vectorization elsewhere in the + * interpreter loop. + */ +#define DONT_SLP_VECTORIZE __attribute__((optimize ("no-tree-slp-vectorize"))) +#else +#define DONT_SLP_VECTORIZE +#endif + +PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag) { _Py_EnsureTstateNotNULL(tstate);