diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 2dd18f6dfc..8aded66453 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -343,7 +343,7 @@ static void QT_FASTCALL convertToRGB32(uint *buffer, int count, const QVector<QR
         buffer[i] = convertPixelToRGB32<Format>(buffer[i]);
 }
 
-#if defined(__SSE2__) && !defined(__SSSE3__) && QT_COMPILER_SUPPORTS_SSSE3
+#if defined(__SSE2_DISABLED__) && !defined(__SSSE3__DISABLED__) && QT_COMPILER_SUPPORTS_SSSE3
 extern const uint * QT_FASTCALL fetchPixelsBPP24_ssse3(uint *dest, const uchar*src, int index, int count);
 #endif
 
@@ -352,7 +352,7 @@ static const uint *QT_FASTCALL fetchRGBToRGB32(uint *buffer, const uchar *src, i
                                                const QVector<QRgb> *, QDitherInfo *)
 {
     constexpr QPixelLayout::BPP BPP = bitsPerPixel<Format>();
-#if defined(__SSE2__) && !defined(__SSSE3__) && QT_COMPILER_SUPPORTS_SSSE3
+#if defined(__SSE2_DISABLED__) && !defined(__SSSE3__DISABLED__) && QT_COMPILER_SUPPORTS_SSSE3
     if (BPP == QPixelLayout::BPP24 && qCpuHasFeature(SSSE3)) {
         // With SSE2 can convertToRGB32 be vectorized, but it takes SSSE3
         // to vectorize the deforested version below.
@@ -443,7 +443,7 @@ static const uint *QT_FASTCALL fetchARGBPMToARGB32PM(uint *buffer, const uchar *
                                                      const QVector<QRgb> *, QDitherInfo *)
 {
     constexpr QPixelLayout::BPP BPP = bitsPerPixel<Format>();
-#if defined(__SSE2__) && !defined(__SSSE3__) && QT_COMPILER_SUPPORTS_SSSE3
+#if defined(__SSE2_DISABLED__) && !defined(__SSSE3__DISABLED__) && QT_COMPILER_SUPPORTS_SSSE3
     if (BPP == QPixelLayout::BPP24 && qCpuHasFeature(SSSE3)) {
         // With SSE2 can convertToRGB32 be vectorized, but it takes SSSE3
         // to vectorize the deforested version below.
@@ -909,7 +909,7 @@ static void QT_FASTCALL storeRGBA8888PMFromARGB32PM(uchar *dest, const uint *src
     UNALIASED_CONVERSION_LOOP(d, src, count, ARGB2RGBA);
 }
 
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
 template<bool RGBA, bool maskAlpha>
 static inline void qConvertARGB32PMToRGBA64PM_sse2(QRgba64 *buffer, const uint *src, int count)
 {
@@ -1066,7 +1066,7 @@ static inline void qConvertARGB32PMToRGBA64PM_neon(QRgba64 *buffer, const uint *
 static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uint *src, int count,
                                                       const QVector<QRgb> *, QDitherInfo *)
 {
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
     qConvertARGB32PMToRGBA64PM_sse2<false, true>(buffer, src, count);
 #elif defined(__ARM_NEON__)
     qConvertARGB32PMToRGBA64PM_neon<false, true>(buffer, src, count);
@@ -1100,7 +1100,7 @@ static const QRgba64 *QT_FASTCALL fetchARGB32ToRGBA64PM(QRgba64 *buffer, const u
 static const QRgba64 *QT_FASTCALL convertARGB32PMToRGBA64PM(QRgba64 *buffer, const uint *src, int count,
                                                             const QVector<QRgb> *, QDitherInfo *)
 {
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
     qConvertARGB32PMToRGBA64PM_sse2<false, false>(buffer, src, count);
 #elif defined(__ARM_NEON__)
     qConvertARGB32PMToRGBA64PM_neon<false, false>(buffer, src, count);
@@ -1153,7 +1153,7 @@ static const QRgba64 *QT_FASTCALL fetchRGBA8888ToRGBA64PM(QRgba64 *buffer, const
 static const QRgba64 *QT_FASTCALL convertRGBA8888PMToRGBA64PM(QRgba64 *buffer, const uint *src, int count,
                                                               const QVector<QRgb> *, QDitherInfo *)
 {
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
     qConvertARGB32PMToRGBA64PM_sse2<true, false>(buffer, src, count);
 #elif defined(__ARM_NEON__)
     qConvertARGB32PMToRGBA64PM_neon<true, false>(buffer, src, count);
@@ -1225,7 +1225,7 @@ static const uint *QT_FASTCALL fetchA2RGB30PMToARGB32PM(uint *buffer, const ucha
     return buffer;
 }
 
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
 template<QtPixelOrder PixelOrder>
 static inline void qConvertA2RGB30PMToRGBA64PM_sse2(QRgba64 *buffer, const uint *src, int count)
 {
@@ -1273,7 +1273,7 @@ template<QtPixelOrder PixelOrder>
 static const QRgba64 *QT_FASTCALL convertA2RGB30PMToRGBA64PM(QRgba64 *buffer, const uint *src, int count,
                                                              const QVector<QRgb> *, QDitherInfo *)
 {
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
     qConvertA2RGB30PMToRGBA64PM_sse2<PixelOrder>(buffer, src, count);
 #else
     for (int i = 0; i < count; ++i)
@@ -1317,7 +1317,7 @@ template<bool RGBA>
 void qt_convertRGBA64ToARGB32(uint *dst, const QRgba64 *src, int count)
 {
     int i = 0;
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
     if (((uintptr_t)dst & 0x7) && count > 0) {
         uint s = (*src++).toArgb32();
         if (RGBA)
@@ -1568,7 +1568,7 @@ static void QT_FASTCALL storeRGB30FromRGBA64PM(uchar *dest, const QRgba64 *src,
                                                const QVector<QRgb> *, QDitherInfo *)
 {
     uint *d = (uint*)dest + index;
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
     qConvertRGBA64PMToA2RGB30PM_sse2<PixelOrder>(d, src, count);
 #else
     for (int i = 0; i < count; ++i)
@@ -2261,7 +2261,7 @@ static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, u
     return (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00);
 }
 
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
 #define interpolate_4_pixels_16_sse2(tl, tr, bl, br, distx, disty, colorMask, v_256, b)  \
 { \
     const __m128i dxdy = _mm_mullo_epi16 (distx, disty); \
@@ -2373,7 +2373,7 @@ enum FastTransformTypes {
 // by performing the x-axis interpolation and joining the RB and AG buffers.
 static void QT_FASTCALL intermediate_adder(uint *b, uint *end, const IntermediateBuffer &intermediate, int offset, int &fx, int fdx)
 {
-#if defined(QT_COMPILER_SUPPORTS_AVX2)
+#if defined(QT_COMPILER_SUPPORTS_AVX2_DISABLED)
     extern void QT_FASTCALL intermediate_adder_avx2(uint *b, uint *end, const IntermediateBuffer &intermediate, int offset, int &fx, int fdx);
     if (qCpuHasFeature(AVX2))
         return intermediate_adder_avx2(b, end, intermediate, offset, fx, fdx);
@@ -2446,7 +2446,7 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_simple_scale_helper(uin
     }
 
     if (blendType != BlendTransformedBilinearTiled) {
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
         const __m128i disty_ = _mm_set1_epi16(disty);
         const __m128i idisty_ = _mm_set1_epi16(idisty);
         const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
@@ -2618,7 +2618,7 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_downscale_helper(uint *
         else if (fdx < 0)
             boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx);
         // A fast middle part without boundary checks
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
         const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
         const __m128i v_256 = _mm_set1_epi16(256);
         const __m128i v_disty = _mm_set1_epi16(disty4);
@@ -2812,7 +2812,7 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper(uint
             boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); \
 
         // until boundedEnd we can now have a fast middle part without boundary checks
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
         const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
         const __m128i v_256 = _mm_set1_epi16(256);
         const __m128i v_fdx = _mm_set1_epi32(fdx*4);
@@ -3579,7 +3579,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf
             while (length) {
                 int len = qMin(length, BufferSize / 2);
                 int disty = (fy & 0x0000ffff);
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
                 const __m128i vdy = _mm_set1_epi16(disty);
                 const __m128i vidy = _mm_set1_epi16(0x10000 - disty);
 #endif
@@ -3591,7 +3591,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf
 
                 for (int i = 0; i < len; ++i) {
                     int distx = (fx & 0x0000ffff);
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
                     __m128i vt = _mm_loadu_si128((const __m128i*)(buf1 + i*2));
                     if (disty) {
                         __m128i vb = _mm_loadu_si128((const __m128i*)(buf2 + i*2));
@@ -3733,7 +3733,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint64(QRgba64 *buf
             while (length) {
                 int len = qMin(length, BufferSize / 2);
                 int disty = (fy & 0x0000ffff);
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
                 const __m128i vdy = _mm_set1_epi16(disty);
                 const __m128i vidy = _mm_set1_epi16(0x10000 - disty);
 #endif
@@ -3745,7 +3745,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint64(QRgba64 *buf
 
                 for (int i = 0; i < len; ++i) {
                     int distx = (fx & 0x0000ffff);
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
                     __m128i vt = _mm_loadu_si128((const __m128i*)(buf1 + i*2));
                     if (disty) {
                         __m128i vb = _mm_loadu_si128((const __m128i*)(buf2 + i*2));
@@ -5296,7 +5296,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData)
     case QImage::Format_RGB16:
         proc = processTextureSpansRGB16[blendType];
         break;
-#if defined(__SSE2__) || defined(__ARM_NEON__) || (Q_PROCESSOR_WORDSIZE == 8)
+#if defined(__SSE2_DISABLED__) || defined(__ARM_NEON__) || (Q_PROCESSOR_WORDSIZE == 8)
     case QImage::Format_ARGB32:
     case QImage::Format_RGBA8888:
 #endif
@@ -5400,7 +5400,7 @@ void qBlendGradient(int count, const QSpan *spans, void *userData)
         if (isVerticalGradient)
             return blend_vertical_gradient_argb(count, spans, userData);
         return blend_src_generic(count, spans, userData);
-#if defined(__SSE2__) || defined(__ARM_NEON__) || (Q_PROCESSOR_WORDSIZE == 8)
+#if defined(__SSE2_DISABLED__) || defined(__ARM_NEON__) || (Q_PROCESSOR_WORDSIZE == 8)
     case QImage::Format_ARGB32:
     case QImage::Format_RGBA8888:
 #endif
@@ -5792,7 +5792,7 @@ static inline int qRgbAvg(QRgb rgb)
 
 static inline QRgb rgbBlend(QRgb d, QRgb s, uint rgbAlpha)
 {
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
     __m128i vd = _mm_cvtsi32_si128(d);
     __m128i vs = _mm_cvtsi32_si128(s);
     __m128i va = _mm_cvtsi32_si128(rgbAlpha);
@@ -6324,7 +6324,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
     },
 };
 
-#if !defined(__SSE2__)
+#if !defined(__SSE2_DISABLED__)
 void qt_memfill64(quint64 *dest, quint64 color, qsizetype count)
 {
     qt_memfill_template<quint64>(dest, color, count);
@@ -6391,13 +6391,13 @@ void qt_memfill16(quint16 *dest, quint16 value, qsizetype count)
     qt_memfill32(reinterpret_cast<quint32*>(dest), value32, count / 2);
 }
 
-#if !defined(__SSE2__) && !defined(__ARM_NEON__) && !defined(__MIPS_DSP__)
+#if !defined(__SSE2_DISABLED__) && !defined(__ARM_NEON__) && !defined(__MIPS_DSP__)
 void qt_memfill32(quint32 *dest, quint32 color, qsizetype count)
 {
     qt_memfill_template<quint32>(dest, color, count);
 }
 #endif
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
 decltype(qt_memfill32_sse2) *qt_memfill32 = nullptr;
 decltype(qt_memfill64_sse2) *qt_memfill64 = nullptr;
 #endif
@@ -6413,7 +6413,7 @@ static void qInitDrawhelperFunctions()
     // Set up basic blend function tables.
     qInitBlendFunctions();
 
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
 #  ifndef __AVX2__
     qt_memfill32 = qt_memfill32_sse2;
     qt_memfill64 = qt_memfill64_sse2;
@@ -6538,7 +6538,7 @@ static void qInitDrawhelperFunctions()
     }
 #endif
 
-#if defined(QT_COMPILER_SUPPORTS_AVX2)
+#if defined(QT_COMPILER_SUPPORTS_AVX2_DISABLED)
     if (qCpuHasFeature(ArchHaswell)) {
         qt_memfill32 = qt_memfill32_avx2;
         qt_memfill64 = qt_memfill64_avx2;
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 37108949d6..02eb2e3578 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -183,7 +183,7 @@ struct quint24 {
 
 void qBlendGradient(int count, const QSpan *spans, void *userData);
 void qBlendTexture(int count, const QSpan *spans, void *userData);
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
 extern void (*qt_memfill64)(quint64 *dest, quint64 value, qsizetype count);
 extern void (*qt_memfill32)(quint32 *dest, quint32 value, qsizetype count);
 #else
@@ -673,7 +673,7 @@ static Q_ALWAYS_INLINE void blend_pixel(quint32 &dst, const quint32 src, const i
     }
 }
 
-#if defined(__SSE2__)
+#if defined(__SSE2_DISABLED__)
 static Q_ALWAYS_INLINE uint interpolate_4_pixels_sse2(__m128i vt, __m128i vb, uint distx, uint disty)
 {
     // First interpolate top and bottom pixels in parallel.
@@ -780,7 +780,7 @@ static inline QRgba64 interpolate256(QRgba64 x, uint alpha1, QRgba64 y, uint alp
     return QRgba64::fromRgba64(multiplyAlpha256(x, alpha1) + multiplyAlpha256(y, alpha2));
 }
 
-#ifdef __SSE2__
+#ifdef __SSE2_DISABLED__
 static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty)
 {
     __m128i vt = _mm_loadu_si128((const __m128i*)t);
@@ -837,7 +837,7 @@ static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba6
     QRgba64 xbot = interpolate256(b[0], idx, b[1], dx);
     return interpolate256(xtop, idy, xbot, dy);
 }
-#endif // __SSE2__
+#endif // __SSE2_DISABLED__
 
 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
 static Q_ALWAYS_INLINE quint32 RGBA2ARGB(quint32 x) {
