aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-03-31 15:56:14 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1993-03-31 15:56:14 -0500
commit0b6b29004875046757143caa8a0552d236d137f0 (patch)
tree68b0b468cde87bfc169391df33529214f9514cff
parent978e895200428deb56d3d1975e7b31415980fe91 (diff)
downloadgcc-0b6b29004875046757143caa8a0552d236d137f0.zip
gcc-0b6b29004875046757143caa8a0552d236d137f0.tar.gz
gcc-0b6b29004875046757143caa8a0552d236d137f0.tar.bz2
(standard_80387_constant_p): When testing for floating-point equality,
make sure we do so inside a region protected from traps. From-SVN: r3962
-rw-r--r--gcc/config/i386/i386.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 960bfd4..fe85584 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -18,6 +18,7 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
+#include <setjmp.h>
#include "config.h"
#include "rtl.h"
#include "regs.h"
@@ -437,21 +438,30 @@ int
standard_80387_constant_p (x)
rtx x;
{
- union real_extract u;
- register double d;
+#if ! defined (REAL_IS_NOT_DOUBLE) || defined (REAL_ARITHMETIC)
+ REAL_VALUE_TYPE d;
+ jmp_buf handler;
+ int is0, is1;
- bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u);
- d = u.d;
+ if (setjmp (handler))
+ return 0;
+
+ set_float_handler (handler);
+ REAL_VALUE_FROM_CONST_DOUBLE (d, x);
+ is0 = REAL_VALUES_EQUAL (d, dconst0);
+ is1 = REAL_VALUES_EQUAL (d, dconst1);
+ set_float_handler (NULL_PTR);
- if (d == 0)
+ if (is0)
return 1;
- if (d == 1)
+ if (is1)
return 2;
/* Note that on the 80387, other constants, such as pi,
are much slower to load as standard constants
than to load from doubles in memory! */
+#endif
return 0;
}