Patchwork [i386] : Fix PR57655, ICE: in create_pre_exit, at mode-switching.c:418

login
register
mail settings
Submitter Uros Bizjak
Date June 20, 2013, 6:11 p.m.
Message ID <CAFULd4Z1mC4gcJ-E0pXSDw+0_cd=tEVTjVKCpGiZN3yhk=hZOg@mail.gmail.com>
Download mbox | patch
Permalink /patch/253054/
State New
Headers show

Comments

Uros Bizjak - June 20, 2013, 6:11 p.m.
Hello!

x86_64 ABI mandates long double returns in x87 register, so it is
invalid to use --mno-fp-ret-in-387. It just happened that vzeroupper
insertion mode-switching pass tripped on invalid register usage.

2013-06-20  Uros Bizjak  <ubizjak@gmail.com>

    PR target/57655
    * config/i386/i386.c (construct_container): Report error if
    long double is used with disabled x87 float returns.

testsuite/ChangeLog:

2013-06-20  Uros Bizjak  <ubizjak@gmail.com>

    PR target/57655
    * gcc.target/i386/pr57655.c: New test.

Patch was tested on x86_64-pc-linux-gnu {,-m32} and was committed to
mainline SVN. The patch will be backported to all release branches.

Uros.

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 200247)
+++ config/i386/i386.c	(working copy)
@@ -6498,7 +6498,7 @@  construct_container (enum machine_mode mode, enum
 
   /* Likewise, error if the ABI requires us to return values in the
      x87 registers and the user specified -mno-80387.  */
-  if (!TARGET_80387 && in_return)
+  if (!TARGET_FLOAT_RETURNS_IN_80387 && in_return)
     for (i = 0; i < n; i++)
       if (regclass[i] == X86_64_X87_CLASS
 	  || regclass[i] == X86_64_X87UP_CLASS
Index: testsuite/gcc.target/i386/pr57655.c
===================================================================
--- testsuite/gcc.target/i386/pr57655.c	(revision 0)
+++ testsuite/gcc.target/i386/pr57655.c	(working copy)
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-mavx -mvzeroupper -mno-fp-ret-in-387" }
+
+/* { dg-error "x87 register return with x87 disabled" "" { target { ! ia32 } } 8 } */
+
+long double
+foo (long double x)
+{
+  return __builtin_ilogbl (x);
+}