aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/complex-3.c15
-rw-r--r--gcc/tree-ssa-ccp.c18
4 files changed, 39 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f2ccbca..8519362 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-18 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR tree-opt/25680
+ * tree-ssa-ccp.c (ccp_fold): Handle store CCP of REALPART_EXPR and
+ IMAGPART_EXPR.
+
2006-02-18 Diego Novillo <dnovillo@redhat.com>
* tree-flow.h (struct var_ann_d): Rename field is_alias_tag to
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index df5cb4c..f705bdd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2006-02-18 Andrew Pinski <pinskia@physics.uc.edu>
+ PR tree-opt/25680
+ * testsuite/gcc.dg/tree-ssa/complex-3.c: New test.
+
+2006-02-18 Andrew Pinski <pinskia@physics.uc.edu>
+
* gcc.dg/tree-ssa/20031106-1.c: Fix the final scan of the
variable to take into account the variable name in the
function header.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/complex-3.c b/gcc/testsuite/gcc.dg/tree-ssa/complex-3.c
index 5f4b110..a354495 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/complex-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/complex-3.c
@@ -1,4 +1,19 @@
/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+int g(_Complex int*);
+int f(void)
+{
+ _Complex int t = 0;
+ int i, j;
+ __real__ t += 2;
+ __imag__ t += 2;
+ return g(&t);
+}
+
+/* { dg-final { scan-tree-dump-times "__complex__" 0 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
+/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
typedef _Complex float COMPLEX_FLOAT;
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 4513f97..ec70c36 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -855,11 +855,19 @@ ccp_fold (tree stmt)
/* If the RHS is a memory load, see if the VUSEs associated with
it are a valid constant for that memory load. */
prop_value_t *val = get_value_loaded_by (stmt, const_val);
- if (val && val->mem_ref
- && operand_equal_p (val->mem_ref, rhs, 0))
- return val->value;
- else
- return NULL_TREE;
+ if (val && val->mem_ref)
+ {
+ if (operand_equal_p (val->mem_ref, rhs, 0))
+ return val->value;
+
+ /* If RHS is extracting REALPART_EXPR or IMAGPART_EXPR of a
+ complex type with a known constant value, return it. */
+ if ((TREE_CODE (rhs) == REALPART_EXPR
+ || TREE_CODE (rhs) == IMAGPART_EXPR)
+ && operand_equal_p (val->mem_ref, TREE_OPERAND (rhs, 0), 0))
+ return fold_build1 (TREE_CODE (rhs), TREE_TYPE (rhs), val->value);
+ }
+ return NULL_TREE;
}
/* Unary operators. Note that we know the single operand must