aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-strength-reduction.c
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>2017-03-20 20:04:25 +0000
committerWilliam Schmidt <wschmidt@gcc.gnu.org>2017-03-20 20:04:25 +0000
commitc34923c44c49a18014b49bf33d180619a9fa0ac9 (patch)
treeccbcf5648b7808b2c65e066ad61a0d0c2d5c120c /gcc/gimple-ssa-strength-reduction.c
parent8afd9c45b6e84193b2fc12a2332191e28cdbdd70 (diff)
downloadgcc-c34923c44c49a18014b49bf33d180619a9fa0ac9.zip
gcc-c34923c44c49a18014b49bf33d180619a9fa0ac9.tar.gz
gcc-c34923c44c49a18014b49bf33d180619a9fa0ac9.tar.bz2
re PR tree-optimization/80054 (ICE in verify_ssa with -O3 -march=broadwell/skylake-avx512)
[gcc] 2017-03-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/80054 * gimple-ssa-strength-reduction.c (all_phi_incrs_profitable): Fail the optimization if a PHI or any of its arguments is not dominated by the candidate's basis. Use gphi* rather than gimple* as appropriate. (replace_profitable_candidates): Clean up a gimple* variable that should be a gphi* variable. [gcc/testsuite] 2017-03-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/80054 * g++.dg/torture/pr80054.C: New file. From-SVN: r246290
Diffstat (limited to 'gcc/gimple-ssa-strength-reduction.c')
-rw-r--r--gcc/gimple-ssa-strength-reduction.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 9ebe198..ca154c5 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -3279,17 +3279,34 @@ insert_initializers (slsr_cand_t c)
}
/* Return TRUE iff all required increments for candidates feeding PHI
- are profitable to replace on behalf of candidate C. */
+ are profitable (and legal!) to replace on behalf of candidate C. */
static bool
-all_phi_incrs_profitable (slsr_cand_t c, gimple *phi)
+all_phi_incrs_profitable (slsr_cand_t c, gphi *phi)
{
unsigned i;
slsr_cand_t basis = lookup_cand (c->basis);
slsr_cand_t phi_cand = *stmt_cand_map->get (phi);
+ /* If the basis doesn't dominate the PHI (including when the PHI is
+ in the same block as the basis), we won't be able to create a PHI
+ using the basis here. */
+ basic_block basis_bb = gimple_bb (basis->cand_stmt);
+ basic_block phi_bb = gimple_bb (phi);
+
+ if (phi_bb == basis_bb
+ || !dominated_by_p (CDI_DOMINATORS, phi_bb, basis_bb))
+ return false;
+
for (i = 0; i < gimple_phi_num_args (phi); i++)
{
+ /* If the PHI arg resides in a block not dominated by the basis,
+ we won't be able to create a PHI using the basis here. */
+ basic_block pred_bb = gimple_phi_arg_edge (phi, i)->src;
+
+ if (!dominated_by_p (CDI_DOMINATORS, pred_bb, basis_bb))
+ return false;
+
tree arg = gimple_phi_arg_def (phi, i);
if (!operand_equal_p (arg, phi_cand->base_expr, 0))
@@ -3298,7 +3315,7 @@ all_phi_incrs_profitable (slsr_cand_t c, gimple *phi)
if (gimple_code (arg_def) == GIMPLE_PHI)
{
- if (!all_phi_incrs_profitable (c, arg_def))
+ if (!all_phi_incrs_profitable (c, as_a <gphi *> (arg_def)))
return false;
}
else
@@ -3565,7 +3582,7 @@ replace_profitable_candidates (slsr_cand_t c)
{
if (phi_dependent_cand_p (c))
{
- gimple *phi = lookup_cand (c->def_phi)->cand_stmt;
+ gphi *phi = as_a <gphi *> (lookup_cand (c->def_phi)->cand_stmt);
if (all_phi_incrs_profitable (c, phi))
{