summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-02 17:09:55 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-02 17:09:55 +0000
commit7c4eaf725162dd0040901bb98e99cb7648e1b63e (patch)
tree121f473987a109b31958eb1bdf6d5fa7f38c2121 /gcc/fold-const.c
parent1c42a59d587cb83125941a70cfb27187be87c54a (diff)
downloadgcc-7c4eaf725162dd0040901bb98e99cb7648e1b63e.tar.gz
* fold-const.c (negate_expr_p, fold_negate_expr): Handle
COMPLEX_EXPR. testsuite: * gcc.dg/builtins-20.c: Add more cases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121511 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e587ea94034..241e9dc5ea5 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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);