summaryrefslogtreecommitdiffstats
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-20 20:12:47 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-20 20:12:47 +0000
commitb4c7e60165ffa8a6faf86c5ba2b5415eacfc5e22 (patch)
tree0571f6c98a4bec862a18389e5fe90d9a038b4cf5 /gcc/builtins.c
parentc2373fdb4d683d1e14f62981bf0b8c1da8b8b684 (diff)
downloadppe42-gcc-b4c7e60165ffa8a6faf86c5ba2b5415eacfc5e22.tar.gz
ppe42-gcc-b4c7e60165ffa8a6faf86c5ba2b5415eacfc5e22.zip
* builtins.c (fold_builtin_cproj): Fold more cases.
testsuite: * gcc.dg/torture/builtin-cproj-1.c: Test more cases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158574 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 8c3c8e0f4be..997c13a5505 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7082,6 +7082,33 @@ fold_builtin_cproj (location_t loc, tree arg, tree type)
else
return arg;
}
+ else if (TREE_CODE (arg) == COMPLEX_EXPR)
+ {
+ tree real = TREE_OPERAND (arg, 0);
+ tree imag = TREE_OPERAND (arg, 1);
+
+ STRIP_NOPS (real);
+ STRIP_NOPS (imag);
+
+ /* If the real part is inf and the imag part is known to be
+ nonnegative, return (inf + 0i). Remember side-effects are
+ possible in the imag part. */
+ if (TREE_CODE (real) == REAL_CST
+ && real_isinf (TREE_REAL_CST_PTR (real))
+ && tree_expr_nonnegative_p (imag))
+ return omit_one_operand_loc (loc, type,
+ build_complex_cproj (type, false),
+ arg);
+
+ /* If the imag part is inf, return (inf+I*copysign(0,imag)).
+ Remember side-effects are possible in the real part. */
+ if (TREE_CODE (imag) == REAL_CST
+ && real_isinf (TREE_REAL_CST_PTR (imag)))
+ return
+ omit_one_operand_loc (loc, type,
+ build_complex_cproj (type, TREE_REAL_CST_PTR
+ (imag)->sign), arg);
+ }
return NULL_TREE;
}
OpenPOWER on IntegriCloud