]> gcc.gnu.org Git - gcc.git/commitdiff
fold-const.c (negate_expr_p, [...]): Handle COMPLEX_EXPR.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Fri, 2 Feb 2007 17:09:55 +0000 (17:09 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Fri, 2 Feb 2007 17:09:55 +0000 (17:09 +0000)
* fold-const.c (negate_expr_p, fold_negate_expr): Handle
COMPLEX_EXPR.

testsuite:
* gcc.dg/builtins-20.c: Add more cases.

From-SVN: r121511

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-20.c

index e5f0a4db038adcf6569ae5a248dc718ba01c4441..5308a3c0f9cd3209b1506d97494199e5c5deba17 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * fold-const.c (negate_expr_p, fold_negate_expr): Handle
+       COMPLEX_EXPR.
+
 2007-02-02  Maxim Kuvyrkov  <mkuvyrkov@ispras.ru>
 
        PR target/29682
index e587ea94034bbb72e1de35b8f9c7d5892cfe8081..241e9dc5ea57cfa6a437ee3f4ffb5a422ed1f24d 100644 (file)
@@ -1011,6 +1011,10 @@ negate_expr_p (tree t)
       return negate_expr_p (TREE_REALPART (t))
             && negate_expr_p (TREE_IMAGPART (t));
 
+    case COMPLEX_EXPR:
+      return negate_expr_p (TREE_OPERAND (t, 0))
+            && negate_expr_p (TREE_OPERAND (t, 1));
+
     case PLUS_EXPR:
       if (HONOR_SIGN_DEPENDENT_ROUNDING (TYPE_MODE (type))
          || HONOR_SIGNED_ZEROS (TYPE_MODE (type)))
@@ -1134,6 +1138,13 @@ fold_negate_expr (tree t)
       }
       break;
 
+    case COMPLEX_EXPR:
+      if (negate_expr_p (t))
+       return fold_build2 (COMPLEX_EXPR, type,
+                           fold_negate_expr (TREE_OPERAND (t, 0)),
+                           fold_negate_expr (TREE_OPERAND (t, 1)));
+      break;
+      
     case NEGATE_EXPR:
       return TREE_OPERAND (t, 0);
 
index fd48ccd53ca4dca87ae9c346a9ffa47e355754b7..f83213d4149362fd2ead1689a3e9dcd15fdebcf3 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * gcc.dg/builtins-20.c: Add more cases.
+
 2007-02-02  Maxim Kuvyrkov  <mkuvyrkov@ispras.ru>
 
        PR target/29682
index 3c8ac76d58836e5ab4e4824a08f8b2a318d98d98..3f36ae4fa7e4cc16ea94957e1a7f8850db42ca82 100644 (file)
@@ -197,6 +197,24 @@ void test2(double x, double y)
   
   if (fmax (x,fmin(y,x)) != x)
     link_error ();
+
+  if ((__complex__ double) x != -(__complex__ double) (-x))
+    link_error ();
+
+  if (x*1i != -(-x*1i))
+    link_error ();
+
+  if (x+(x-y)*1i != -(-x+(y-x)*1i))
+    link_error ();
+
+  if (x+(x-y)*1i != -(-x-(x-y)*1i))
+    link_error ();
+
+  if (ccos(tan(x)+sin(y)*1i) != ccos(-tan(-x)+-sin(-y)*1i))
+    link_error ();
+
+  if (ccos(tan(x)+sin(x-y)*1i) != ccos(-tan(-x)-sin(y-x)*1i))
+    link_error ();
 }
 
 void test3(__complex__ double x, __complex__ double y, int i)
@@ -389,6 +407,21 @@ void test2f(float x, float y)
   
   if (fmaxf (x,fminf(y,x)) != x)
     link_error ();
+
+  if ((__complex__ float) x != -(__complex__ float) (-x))
+    link_error ();
+
+  if (x+(x-y)*1i != -(-x+(y-x)*1i))
+    link_error ();
+
+  if (x+(x-y)*1i != -(-x-(x-y)*1i))
+    link_error ();
+
+  if (ccosf(tanf(x)+sinf(y)*1i) != ccosf(-tanf(-x)+-sinf(-y)*1i))
+    link_error ();
+
+  if (ccosf(tanf(x)+sinf(x-y)*1i) != ccosf(-tanf(-x)-sinf(y-x)*1i))
+    link_error ();
 }
 
 void test3f(__complex__ float x, __complex__ float y, int i)
@@ -581,6 +614,21 @@ void test2l(long double x, long double y)
   
   if (fmaxl (x,fminl(y,x)) != x)
     link_error ();
+
+  if ((__complex__ long double) x != -(__complex__ long double) (-x))
+    link_error ();
+
+  if (x+(x-y)*1i != -(-x+(y-x)*1i))
+    link_error ();
+
+  if (x+(x-y)*1i != -(-x-(x-y)*1i))
+    link_error ();
+
+  if (ccosl(tanl(x)+sinl(y)*1i) != ccosl(-tanl(-x)+-sinl(-y)*1i))
+    link_error ();
+
+  if (ccosl(tanl(x)+sinl(x-y)*1i) != ccosl(-tanl(-x)-sinl(y-x)*1i))
+    link_error ();
 }
 
 void test3l(__complex__ long double x, __complex__ long double y, int i)
This page took 0.148665 seconds and 5 git commands to generate.