summaryrefslogtreecommitdiffstats
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index c8ab92a896b..f883e373cc4 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1868,6 +1868,11 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
/* Strip the ADDR_EXPR. */
base = TREE_OPERAND (base, 0);
+ /* Fold away CONST_DECL to its value, if the type is scalar. */
+ if (TREE_CODE (base) == CONST_DECL
+ && is_gimple_min_invariant (DECL_INITIAL (base)))
+ return DECL_INITIAL (base);
+
/* Try folding *(&B+O) to B[X]. */
t = maybe_fold_offset_to_array_ref (base, offset, TREE_TYPE (expr));
if (t)
OpenPOWER on IntegriCloud