OSDN Git Service

* simplify-rtx.c (simplify_relational_operation): Optimize
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 20 Jul 2002 22:24:58 +0000 (22:24 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 20 Jul 2002 22:24:58 +0000 (22:24 +0000)
abs(x) < 0.0 (and abs(x) >= 0.0 when using -ffast-math).

* gcc.c-torture/execute/20020720-1.c: New test case.

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

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20020720-1.c [new file with mode: 0644]

index fe31faf..833b857 100644 (file)
@@ -1,3 +1,8 @@
+2002-07-20  Roger Sayle  <roger@eyesopen.com>
+
+       * simplify-rtx.c (simplify_relational_operation): Optimize
+       abs(x) < 0.0 (and abs(x) >= 0.0 when using -ffast-math).
+
 2002-07-20  Michae Matz  <matz@suse.de>
 
        * ra-build.c: (remember_web_was_spilled): Use GENERAL_REGS.
index 95a2af0..b98c475 100644 (file)
@@ -2075,6 +2075,28 @@ simplify_relational_operation (code, mode, op0, op1)
            return const0_rtx;
          break;
 
+       case LT:
+         /* Optimize abs(x) < 0.0.  */
+         if (trueop1 == CONST0_RTX (mode))
+           {
+             tem = GET_CODE (trueop0) == FLOAT_EXTEND ? XEXP (trueop0, 0)
+                                                      : trueop0;
+             if (GET_CODE (tem) == ABS)
+               return const0_rtx;
+           }
+         break;
+
+       case GE:
+         /* Optimize abs(x) >= 0.0.  */
+         if (trueop1 == CONST0_RTX (mode) && !HONOR_NANS (mode))
+           {
+             tem = GET_CODE (trueop0) == FLOAT_EXTEND ? XEXP (trueop0, 0)
+                                                      : trueop0;
+             if (GET_CODE (tem) == ABS)
+               return const1_rtx;
+           }
+         break;
+
        default:
          break;
        }
index 91c63ea..5388182 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-20  Roger Sayle  <roger@eyesopen.com>
+
+       * gcc.c-torture/execute/20020720-1.c: New testcase.
+
 2002-07-20  Neil Booth  <neil@daikokuya.co.uk>
 
        * gcc.dg/cpp/Wsignprom.c: New tests.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20020720-1.c b/gcc/testsuite/gcc.c-torture/execute/20020720-1.c
new file mode 100644 (file)
index 0000000..c70bc74
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (C) 2002  Free Software Foundation.
+
+   Ensure that fabs(x) < 0.0 optimization is working.
+
+   Written by Roger Sayle, 20th July 2002.  */
+
+extern void abort (void);
+extern double fabs (double);
+extern void link_error (void);
+
+void
+foo (double x)
+{
+  double p, q;
+
+  p = fabs (x);
+  q = 0.0;
+  if (p < q)
+    link_error ();
+}
+
+int
+main()
+{
+  foo (1.0);
+  return 0;
+}
+
+#ifndef __OPTIMIZE__
+void
+link_error ()
+{
+  abort ();
+}
+#endif
+