From: Richard Guenther Date: Wed, 16 Mar 2011 15:55:48 +0000 (+0000) Subject: re PR tree-optimization/48149 (Piecewise complex pass-through not optimized) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b0081eca46587e27c16abc633fd199832616243;p=gcc.git re PR tree-optimization/48149 (Piecewise complex pass-through not optimized) 2011-03-16 Richard Guenther PR tree-optimization/48149 * fold-const.c (fold_binary_loc): Fold COMPLEX_EXPR , IMAGPART_EXPR >. * gcc.dg/fold-complex-1.c: New testcase. From-SVN: r171048 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a535ac1e10e..c19efcb5d9f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-16 Richard Guenther + + PR tree-optimization/48149 + * fold-const.c (fold_binary_loc): Fold + COMPLEX_EXPR , IMAGPART_EXPR >. + 2011-03-16 Richard Guenther PR tree-optimization/26134 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f8630a2baa3..9baa9eb24bc 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -13176,6 +13176,14 @@ fold_binary_loc (location_t loc, || (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)) return build_complex (type, arg0, arg1); + if (TREE_CODE (arg0) == REALPART_EXPR + && TREE_CODE (arg1) == IMAGPART_EXPR + && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg0, 0))) + == TYPE_MAIN_VARIANT (type)) + && operand_equal_p (TREE_OPERAND (arg0, 0), + TREE_OPERAND (arg1, 0), 0)) + return omit_one_operand_loc (loc, type, TREE_OPERAND (arg0, 0), + TREE_OPERAND (arg1, 0)); return NULL_TREE; case ASSERT_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index efb61404df9..a9db0b7eb9d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-16 Richard Guenther + + PR tree-optimization/48149 + * gcc.dg/fold-complex-1.c: New testcase. + 2011-03-16 Richard Guenther PR testsuite/48147 diff --git a/gcc/testsuite/gcc.dg/fold-complex-1.c b/gcc/testsuite/gcc.dg/fold-complex-1.c new file mode 100644 index 00000000000..a9ba0fd59c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-complex-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -fdump-tree-original" } */ + +_Complex float +foo (_Complex float x) +{ + return __real x + 1.0iF * __imag x; +} + +/* { dg-final { scan-tree-dump-times "COMPLEX_EXPR" 0 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */