Skip EXT_REX_SSE_REG_P for vzeroupper optimization since upper 16 vector
registers don't trigger SSE <-> AVX transition penalty.
gcc/
PR target/95791
* config/i386/i386.c (ix86_dirflag_mode_needed): Skip
EXT_REX_SSE_REG_P.
gcc/testsuite/
PR target/95791
* gcc.target/i386/pr95791.c: New test.
static bool
ix86_check_avx_upper_register (const_rtx exp)
{
- return SSE_REG_P (exp) && GET_MODE_BITSIZE (GET_MODE (exp)) > 128;
+ return (SSE_REG_P (exp)
+ && !EXT_REX_SSE_REG_P (exp)
+ && GET_MODE_BITSIZE (GET_MODE (exp)) > 128);
}
/* Return needed mode for entity in optimize_mode_switching pass. */
--- /dev/null
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -mavx512f -mvzeroupper" } */
+
+void
+f(void)
+{
+ __asm__ __volatile__("" ::: "zmm16");
+}
+
+/* { dg-final { scan-assembler-not "vzeroupper" } } */