summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2006-02-18 21:09:35 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2006-02-18 13:09:35 -0800
commitadd9e6d3bd21e14543ab014f938ba227ad2857bf (patch)
tree685297e000b9ec35689a0cf68b160a3e8c08680c /gcc/tree-ssa-ccp.c
parentc8ca29f104d4e1294ecd13288d2e02b5f5e29e42 (diff)
downloadgcc-add9e6d3bd21e14543ab014f938ba227ad2857bf.tar.gz
re PR tree-optimization/25680 (Store CCP does not understand REALPART_EXPR < COMPLEX_CST >)
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 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/25680 * testsuite/gcc.dg/tree-ssa/complex-3.c: New test. From-SVN: r111251
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 4513f977cd0..ec70c36d6d3 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