aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2015-08-11 12:34:06 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-08-11 12:34:06 +0000
commita6810021afdc4e05a44d7c56682eebe9452c359d (patch)
tree975f335631ad9587ccc537fcc29be670766001e3 /gcc/tree-ssa-phiopt.c
parent739a838e18d8ce5dfbaf3bc40b3b92fd6111a458 (diff)
downloadgcc-a6810021afdc4e05a44d7c56682eebe9452c359d.zip
gcc-a6810021afdc4e05a44d7c56682eebe9452c359d.tar.gz
gcc-a6810021afdc4e05a44d7c56682eebe9452c359d.tar.bz2
tree-ssa-phiopt.c (minmax_replacement): Create new ssa name if we're not the only contributor to target phi.
* tree-ssa-phiopt.c (minmax_replacement): Create new ssa name if we're not the only contributor to target phi. testsuite/ * c-c++-common/dfp/operator-comma.c: Call init function. * c-c++-common/dfp/convert-dfp-2.c: New test. From-SVN: r226778
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r--gcc/tree-ssa-phiopt.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 633ccc7..d46ba62 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1277,8 +1277,16 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
gsi_move_before (&gsi_from, &gsi);
}
+ /* Create an SSA var to hold the min/max result. If we're the only
+ things setting the target PHI, then we can clone the PHI
+ variable. Otherwise we must create a new one. */
+ result = PHI_RESULT (phi);
+ if (EDGE_COUNT (gimple_bb (phi)->preds) == 2)
+ result = duplicate_ssa_name (result, NULL);
+ else
+ result = make_ssa_name (TREE_TYPE (result));
+
/* Emit the statement to compute min/max. */
- result = duplicate_ssa_name (PHI_RESULT (phi), NULL);
new_stmt = gimple_build_assign (result, minmax, arg0, arg1);
gsi = gsi_last_bb (cond_bb);
gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);