diff options
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 31ca0e1..b3efa99 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1126,6 +1126,27 @@ valueize_op (tree op) return op; } +/* Return the constant value for OP, but signal to not follow SSA + edges if the definition may be simulated again. */ + +static tree +valueize_op_1 (tree op) +{ + if (TREE_CODE (op) == SSA_NAME) + { + tree tem = get_constant_value (op); + if (tem) + return tem; + /* If the definition may be simulated again we cannot follow + this SSA edge as the SSA propagator does not necessarily + re-visit the use. */ + gimple def_stmt = SSA_NAME_DEF_STMT (op); + if (prop_simulate_again_p (def_stmt)) + return NULL_TREE; + } + return op; +} + /* CCP specific front-end to the non-destructive constant folding routines. @@ -1158,7 +1179,8 @@ ccp_fold (gimple stmt) case GIMPLE_ASSIGN: case GIMPLE_CALL: - return gimple_fold_stmt_to_constant_1 (stmt, valueize_op); + return gimple_fold_stmt_to_constant_1 (stmt, + valueize_op, valueize_op_1); default: gcc_unreachable (); |