OSDN Git Service

* rtlanal.c (may_trap_p): Check operand modes of COMPARE.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Oct 2000 07:46:09 +0000 (07:46 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Oct 2000 07:46:09 +0000 (07:46 +0000)
* gcc.dg/20001013-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36878 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/rtlanal.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20001013-1.c [new file with mode: 0644]

index 92a3b4e..566515c 100644 (file)
@@ -1,3 +1,7 @@
+2000-10-16  Jakub Jelinek  <jakub@redhat.com>
+
+       * rtlanal.c (may_trap_p): Check operand modes of COMPARE.
+
 2000-10-14  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * PROBLEMS: Remove.
index 8edcdbc..52a430b 100644 (file)
@@ -1930,6 +1930,17 @@ may_trap_p (x)
         certainly may trap.  */
       return 1;
 
+    case COMPARE:
+      /* Any floating comparison may trap.  */
+      if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
+       return 1;
+      /* But often the compare has some CC mode, so check operand
+        modes as well.  */
+      if (GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) == MODE_FLOAT
+         || GET_MODE_CLASS (GET_MODE (XEXP (x, 1))) == MODE_FLOAT)
+       return 1;
+      break;
+
     default:
       /* Any floating arithmetic may trap.  */
       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
index 2e6782f..f9b2a92 100644 (file)
@@ -1,3 +1,7 @@
+2000-10-16  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20001013-1.c: New test.
+
 2000-10-15  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcc.dg/c90-printf-2.c, gcc.dg/c90-scanf-2.c: Determine the type
diff --git a/gcc/testsuite/gcc.dg/20001013-1.c b/gcc/testsuite/gcc.dg/20001013-1.c
new file mode 100644 (file)
index 0000000..f154cfd
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do run { target sparc*-*-* } } */
+/* { dg-options "-O2 -mvis" } */
+
+int l;
+
+int baz (double x)
+{
+  return l == 0;
+}
+
+double bar (double x)
+{
+  return 1.0;
+}
+
+double foo (double x)
+{
+  if (l == -1 || baz (x)) return x;
+  if (x < 0.0)
+    return bar (x);
+  else
+    return 0.0;
+}
+
+union {
+  double d;
+  long long l;
+} x = { l: 0x7ff8000000000000LL }, y;
+
+main ()
+{
+  unsigned int fsr = 0;
+  __asm __volatile ("ld %0, %%fsr" : : "m" (fsr));
+  y.d = foo (x.d);
+  __asm __volatile ("st %%fsr, %0" : "=m" (fsr));
+  if (x.l != y.l || (fsr & 0x3ff))
+    abort ();
+  exit (0);
+}