aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-pre.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-08-12 12:58:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-08-12 12:58:15 +0000
commite373dd067e6f29cd333cddd741611f5979718c58 (patch)
tree9f4ca179884496904f5a175a84357487283ad659 /gcc/tree-ssa-pre.c
parent20d1af89b40d0a939a7afefeecf6652bd587e18b (diff)
downloadgcc-e373dd067e6f29cd333cddd741611f5979718c58.zip
gcc-e373dd067e6f29cd333cddd741611f5979718c58.tar.gz
gcc-e373dd067e6f29cd333cddd741611f5979718c58.tar.bz2
re PR tree-optimization/57326 (Piecewise folding of operations on PHI nodes)
2016-08-12 Richard Biener <rguenther@suse.de> PR tree-optimization/57326 * tree-ssa-pre.c (fully_constant_expression): Handle simplification returning an SSA name. (phi_translate_1): When fully_constant_expression returns a NAME make sure we have a leader for it. * gcc.dg/tree-ssa/ssa-pre-32.c: New testcase. * gcc.dg/tree-ssa/loadpre14.c: Adjust. * gcc.dg/tree-ssa/pr35287.c: Likewise. * gcc.target/i386/pr45685.c: Likewise. * gcc.dg/tree-ssa/predcom-1.c: Disable PRE. * gcc.dg/tree-ssa/predcom-2.c: Likewise. * gcc.dg/tree-ssa/predcom-3.c: Likewise. * gcc.dg/tree-ssa/ssa-sink-10.c: Likewise. * gfortran.dg/pr34163.f90: Likewise. From-SVN: r239414
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r--gcc/tree-ssa-pre.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index c2c7495..edc3fdf 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -1201,7 +1201,7 @@ get_or_alloc_expr_for (tree t)
}
/* Return the folded version of T if T, when folded, is a gimple
- min_invariant. Otherwise, return T. */
+ min_invariant or an SSA name. Otherwise, return T. */
static pre_expr
fully_constant_expression (pre_expr e)
@@ -1218,10 +1218,8 @@ fully_constant_expression (pre_expr e)
return e;
if (is_gimple_min_invariant (res))
return get_or_alloc_expr_for_constant (res);
- /* We might have simplified the expression to a
- SSA_NAME for example from x_1 * 1. But we cannot
- insert a PHI for x_1 unconditionally as x_1 might
- not be available readily. */
+ if (TREE_CODE (res) == SSA_NAME)
+ return get_or_alloc_expr_for_name (res);
return e;
}
case REFERENCE:
@@ -1464,7 +1462,20 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
constant = fully_constant_expression (expr);
PRE_EXPR_NARY (expr) = nary;
if (constant != expr)
- return constant;
+ {
+ /* For non-CONSTANTs we have to make sure we can eventually
+ insert the expression. Which means we need to have a
+ leader for it. */
+ if (constant->kind != CONSTANT)
+ {
+ unsigned value_id = get_expr_value_id (constant);
+ constant = find_leader_in_sets (value_id, set1, set2);
+ if (constant)
+ return constant;
+ }
+ else
+ return constant;
+ }
tree result = vn_nary_op_lookup_pieces (newnary->length,
newnary->opcode,