PR middle-end/29335
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 20 Jan 2007 00:33:00 +0000 (00:33 +0000)
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 20 Jan 2007 00:33:00 +0000 (00:33 +0000)
* builtins.c (fold_builtin_1): Handle builtin fdim.

testsuite:
* gcc.dg/torture/builtin-math-3.c: Test fdim.

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

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/builtin-math-3.c

index c4aede6..5a9e553 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       PR middle-end/29335
+       * builtins.c (fold_builtin_1): Handle builtin fdim.
+
 2007-01-20  Jan Hubicka  <jh@suse.cz>
 
         * tree-ssa.c (init_tree_ssa): Do not call init_alias_heapvars.
index 82e5a1e..bf57c7b 100644 (file)
@@ -9469,6 +9469,13 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore)
                             type, mpfr_atan2);
     break;
 
+    CASE_FLT_FN (BUILT_IN_FDIM):
+      if (validate_arglist (arglist, REAL_TYPE, REAL_TYPE, VOID_TYPE))
+       return do_mpfr_arg2 (TREE_VALUE (arglist),
+                            TREE_VALUE (TREE_CHAIN (arglist)),
+                            type, mpfr_dim);
+    break;
+
     CASE_FLT_FN (BUILT_IN_FMA):
       if (validate_arglist (arglist, REAL_TYPE, REAL_TYPE, REAL_TYPE, VOID_TYPE))
        return do_mpfr_arg3 (TREE_VALUE (arglist),
index 640d3b7..e9f9c9f 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * gcc.dg/torture/builtin-math-3.c: Test fdim.
+
 2007-01-19  Mike Stump  <mrs@apple.com>
 
        * gcc.dg/darwin-ld-6.c: Remove, tests a linker flag that is going
index 67304f8..b347dcc 100644 (file)
@@ -294,6 +294,16 @@ int main (void)
   TESTIT2_R (atan2, -1.0, 0.0, -1.58, -1.57); /* atan2(-1,0) == -pi/2 */
   TESTIT2_R (atan2, 1.0, 0.0, 1.57, 1.58); /* atan2(1,0) == pi/2 */
 
+  TESTIT2 (fdim, 0.0, 0.0, 0.0); /* fdim(0,0) == 0 */
+  TESTIT2 (fdim, -0.0, 0.0, 0.0); /* fdim(-0,0) == 0 */
+  TESTIT2 (fdim, 0.0, -0.0, 0.0); /* fdim(0,-0) == 0 */
+  TESTIT2 (fdim, -0.0, -0.0, 0.0); /* fdim(-0,-0) == 0 */
+  TESTIT2 (fdim, 5.0, 5.0, 0.0); /* fdim(5,5) == 0 */
+  TESTIT2 (fdim, 5.0, 6.0, 0.0); /* fdim(5,6) == 0 */
+  TESTIT2 (fdim, 6.0, 5.0, 1.0); /* fdim(6,5) == 1 */
+  TESTIT2 (fdim, -5.0, -6.0, 1.0); /* fdim(-5,-6) == 1 */
+  TESTIT2 (fdim, -6.0, -5.0, 0.0); /* fdim(-6,-5) == 0 */
+
   TESTIT2 (fmin, 5.0, 6.0, 5.0); /* fmin(5,6) == 5 */
   TESTIT2 (fmin, 6.0, 5.0, 5.0); /* fmin(6,5) == 5 */
   TESTIT2 (fmin, -5.0, -6.0, -6.0); /* fmin(-5,-6) == -6 */