summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-19 13:58:27 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-19 13:58:27 +0000
commitec11da34ececa49554fc8834f0379f25696253f6 (patch)
treeab6e2c78aa78e165e6c5f5307a23b2f3a4fa5fff /gcc/match.pd
parentb6ec4d7aba7569f3e7f786a61ed2bb5b33ab9058 (diff)
downloadgcc-ec11da34ececa49554fc8834f0379f25696253f6.tar.gz
2015-10-19 Richard Biener <rguenther@suse.de>
* gimple-fold.c (gimple_phi_nonnegative_warnv_p): New function. (gimple_stmt_nonnegative_warnv_p): Use it. * match.pd (CPROJ): New operator list. (cproj (complex ...)): Move simplifications from ... * builtins.c (fold_builtin_cproj): ... here. * gcc.dg/torture/builtin-cproj-1.c: Skip for -O0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228970 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index f3813d87b5d..98f4b2cbc35 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3. If not see
(define_operator_list TAN BUILT_IN_TANF BUILT_IN_TAN BUILT_IN_TANL)
(define_operator_list COSH BUILT_IN_COSHF BUILT_IN_COSH BUILT_IN_COSHL)
(define_operator_list CEXPI BUILT_IN_CEXPIF BUILT_IN_CEXPI BUILT_IN_CEXPIL)
+(define_operator_list CPROJ BUILT_IN_CPROJF BUILT_IN_CPROJ BUILT_IN_CPROJL)
/* Simplifications of operations with one constant operand and
simplifications to constants or single values. */
@@ -2361,6 +2362,32 @@ along with GCC; see the file COPYING3. If not see
(cbrts (pows tree_expr_nonnegative_p@0 @1))
(pows @0 (mult @1 { build_real_truncate (type, dconst_third ()); })))))
+/* If the real part is inf and the imag part is known to be
+ nonnegative, return (inf + 0i). */
+(simplify
+ (CPROJ (complex REAL_CST@0 tree_expr_nonnegative_p@1))
+ (if (real_isinf (TREE_REAL_CST_PTR (@0)))
+ (with
+ {
+ REAL_VALUE_TYPE rinf;
+ real_inf (&rinf);
+ }
+ { build_complex (type, build_real (TREE_TYPE (type), rinf),
+ build_zero_cst (TREE_TYPE (type))); })))
+/* If the imag part is inf, return (inf+I*copysign(0,imag)). */
+(simplify
+ (CPROJ (complex @0 REAL_CST@1))
+ (if (real_isinf (TREE_REAL_CST_PTR (@1)))
+ (with
+ {
+ REAL_VALUE_TYPE rinf, rzero = dconst0;
+ real_inf (&rinf);
+ rzero.sign = TREE_REAL_CST_PTR (@1)->sign;
+ }
+ { build_complex (type, build_real (TREE_TYPE (type), rinf),
+ build_real (TREE_TYPE (type), rzero)); })))
+
+
/* Narrowing of arithmetic and logical operations.
These are conceptually similar to the transformations performed for