public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-4741] i386: Fix PR97715
@ 2020-11-05 14:58 Qing Zhao
  0 siblings, 0 replies; only message in thread
From: Qing Zhao @ 2020-11-05 14:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:cc32e81cdbb7696cd571bdb5ffe52f228f125df5

commit r11-4741-gcc32e81cdbb7696cd571bdb5ffe52f228f125df5
Author: qing zhao <qinzhao@gcc.gnu.org>
Date:   Thu Nov 5 15:57:46 2020 +0100

    i386: Fix PR97715
    
    This change fixes a bug in the i386 backend when adding
    -fzero-call-used-regs=all on a target that has no x87
    registers.
    
    When there is no x87 registers available, we should not
    zero stack registers.
    
    gcc/ChangeLog:
    
            PR target/97715
            * config/i386/i386.c (zero_all_st_registers): Return
            earlier when the FPU is disabled.
    
    gcc/testsuite/ChangeLog:
    
            PR target/97715
            * gcc.target/i386/zero-scratch-regs-32.c: New test.

Diff:
---
 gcc/config/i386/i386.c                               |  5 +++++
 gcc/testsuite/gcc.target/i386/zero-scratch-regs-32.c | 11 +++++++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6fc6228a26e..789ef727cf8 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3640,6 +3640,11 @@ zero_all_vector_registers (HARD_REG_SET need_zeroed_hardregs)
 static bool
 zero_all_st_registers (HARD_REG_SET need_zeroed_hardregs)
 {
+
+  /* If the FPU is disabled, no need to zero all st registers.  */
+  if (! (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387))
+    return false;
+
   unsigned int num_of_st = 0;
   for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
     if ((STACK_REGNO_P (regno) || MMX_REGNO_P (regno))
diff --git a/gcc/testsuite/gcc.target/i386/zero-scratch-regs-32.c b/gcc/testsuite/gcc.target/i386/zero-scratch-regs-32.c
new file mode 100644
index 00000000000..ca3261fe5ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/zero-scratch-regs-32.c
@@ -0,0 +1,11 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fzero-call-used-regs=all -mno-80387" } */
+
+int
+foo (int x)
+{
+  return (x + 1);
+}
+
+/* { dg-final { scan-assembler-not "fldz" } } */
+


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-05 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 14:58 [gcc r11-4741] i386: Fix PR97715 Qing Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).