commit
9804b23198b39f85a7258be556c5e8aed44b9efc
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun Apr 13 11:38:24 2025 -0700
x86: Add preserve_none and update no_caller_saved_registers attributes
allowed MMX/80387 instructions in functions with no_caller_saved_registers
attribute by accident. Update ix86_set_current_function to properly
check if MMX and 80387 are enabled.
gcc/
PR target/121540
* config/i386/i386-options.cc (ix86_set_current_function):
Properly check if MMX and 80387 are enabled.
gcc/testsuite/
PR target/121540
* gcc.target/i386/no-callee-saved-19a.c (dg-options): Add
"-mno-avx -mno-mmx -mno-80387"
* gcc.target/i386/no-callee-saved-19b.c: Likewise.
* gcc.target/i386/no-callee-saved-19c.c: Likewise.
* gcc.target/i386/no-callee-saved-19d.c: Likewise.
* gcc.target/i386/no-callee-saved-19e.c: Likewise.
* gcc.target/i386/pr121208-1a.c: Likewise.
* gcc.target/i386/pr121208-1b.c: Likewise.
* gcc.target/i386/pr121540-1.c: New test.
* gcc.target/i386/pr121540-2.c: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
isa = "AVX";
else if (cfun->machine->func_type != TYPE_NORMAL)
isa = "SSE";
+ else if (TARGET_MMX)
+ isa = "MMX/3Dnow";
+ else if (TARGET_80387)
+ isa = "80387";
else
isa = NULL;
}
/* { dg-do compile { target { *-*-linux* && lp64 } } } */
-/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
/* { dg-do compile { target { *-*-linux* && maybe_x32 } } } */
-/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
/* { dg-do compile { target { *-*-linux* && ia32 } } } */
-/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
/* { dg-do compile { target { *-*-linux* && lp64 } } } */
-/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
/* { dg-do compile { target { *-*-linux* && maybe_x32 } } } */
-/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
/* { dg-do compile { target *-*-linux* } } */
-/* { dg-options "-O2 -fPIC -mno-80387 -mtls-dialect=gnu" } */
+/* { dg-options "-O2 -fPIC -mno-avx -mno-mmx -mno-80387 -mtls-dialect=gnu" } */
extern __thread int bar;
extern void func (void);
/* { dg-do compile { target *-*-linux* } } */
-/* { dg-options "-O2 -fPIC -mno-80387 -mtls-dialect=gnu2" } */
+/* { dg-options "-O2 -fPIC -mno-avx -mno-mmx -mno-80387 -mtls-dialect=gnu2" } */
#include "pr121208-1a.c"
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64" } */
+
+void
+ __attribute__ ((no_caller_saved_registers))
+fn (void)
+{ /* { dg-message "sorry, unimplemented: MMX/3Dnow instructions aren't allowed" } */
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64 -mno-mmx" } */
+
+void
+ __attribute__ ((no_caller_saved_registers))
+fn (void)
+{ /* { dg-message "sorry, unimplemented: 80387 instructions aren't allowed" } */
+}