Fix fastmath-specific crash PR 7133.
authorDale Johannesen <dalej@gcc.gnu.org>
Mon, 21 Oct 2002 21:56:40 +0000 (21:56 +0000)
committerDale Johannesen <dalej@gcc.gnu.org>
Mon, 21 Oct 2002 21:56:40 +0000 (21:56 +0000)
From-SVN: r58389

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/gcc.dg/fastmath-1.c [new file with mode: 0644]

index 81a7db7c661251fc82b82863406e46356ccf8ffc..40370bfd6af0c2a0a2d0119f2cd4980d27c761fa 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-21  Dale Johannesen  <dalej@apple.com>
+
+        * config/rs6000/rs6000.c (rs6000_reverse_condition): Handle
+           unsafe math reversals correctly for RTL generation.
+         (output_cbranch):  Replace rs6000_reverse_condition call
+           by its former definition.
+
 2002-10-21  Jakub Jelinek  <jakub@redhat.com>
 
        * config/i386/i386.c (x86_64_sign_extended_value): Add allow_rip
@@ -355,6 +362,7 @@ Sat Oct 19 10:46:52 CEST 2002  Jan Hubicka  <jh@suse.cz>
 
        * doc/c-tree.texi: Update description of COND_EXPR tree nodes.
 
+>>>>>>> 1.15743
 2002-10-17  Geoffrey Keating  <geoffk@apple.com>
 
        * config/rs6000/rs6000.h (HARD_REGNO_MODE_OK): Allow arbitrary modes
index dcee67b020a8906bdeb433b849023b386e845eee..cf930e9e0e5b6ff9bcdbaa8a541659cfc61ff008 100644 (file)
@@ -8125,7 +8125,7 @@ rs6000_reverse_condition (mode, code)
 {
   /* Reversal of FP compares takes care -- an ordered compare
      becomes an unordered compare and vice versa.  */
-  if (mode == CCFPmode)
+  if (mode == CCFPmode && !flag_unsafe_math_optimizations)
     return reverse_condition_maybe_unordered (code);
   else
     return reverse_condition (code);
@@ -8397,7 +8397,14 @@ output_cbranch (op, label, reversed, insn)
      reverse_condition_maybe_unordered here always but this
      makes the resulting assembler clearer.  */
   if (really_reversed)
-    code = rs6000_reverse_condition (mode, code);
+    {
+      /* Reversal of FP compares takes care -- an ordered compare
+        becomes an unordered compare and vice versa.  */
+      if (mode == CCFPmode)
+       code = reverse_condition_maybe_unordered (code);
+      else
+       code = reverse_condition (code);
+    }
 
   if ((TARGET_SPE && TARGET_HARD_FLOAT) && mode == CCFPmode)
     {
diff --git a/gcc/testsuite/gcc.dg/fastmath-1.c b/gcc/testsuite/gcc.dg/fastmath-1.c
new file mode 100644 (file)
index 0000000..898c183
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math" } */
+
+int foo ( float* dists,  int k) 
+{ 
+if ( ( dists [ 0 ] > 0 ) == ( dists [ 1 ] > 0 ) ) 
+  return k;
+return 0;
+} 
+main() {
+  float dists[16] = { 0., 1., 1., 0., 0., -1., -1., 0.,
+                    1., 1., 1., -1., -1., 1., -1., -1. };
+  if ( foo(&dists[0], 1) +
+       foo(&dists[2], 2) +
+       foo(&dists[4], 4) +
+       foo(&dists[6], 8) +
+       foo(&dists[8], 16) +
+       foo(&dists[10], 32) +
+       foo(&dists[12], 64) +
+       foo(&dists[14], 128)
+       != 156)
+    abort();
+}
\ No newline at end of file