From 3e75ec3fab878ec6ebde748e6b57fdcaec8fd4ea Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Wed, 30 Aug 2017 20:04:07 +0000 Subject: [PATCH] re PR tree-optimization/81987 (ICE in verify_ssa with -O3 -march=skylake-avx512) [gcc] 2017-08-30 Bill Schmidt PR tree-optimization/81987 * gimple-ssa-strength-reduction.c (insert_initializers): Don't insert an initializer in a location not dominated by the stride definition. [gcc/testsuite] 2017-08-30 Bill Schmidt PR tree-optimization/81987 * g++.dg/torture/pr81987.C: New file. From-SVN: r251547 --- gcc/ChangeLog | 7 +++ gcc/gimple-ssa-strength-reduction.c | 17 +++++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/g++.dg/torture/pr81987.C | 61 ++++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr81987.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9106eb735dc..379be0a3510 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-08-30 Bill Schmidt + + PR tree-optimization/81987 + * gimple-ssa-strength-reduction.c (insert_initializers): Don't + insert an initializer in a location not dominated by the stride + definition. + 2017-08-30 Eric Botcazou * tree-eh.c (lower_try_finally_switch): Set the location of the finally diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 8fe7c1776c1..6e3e93db053 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -3340,6 +3340,23 @@ insert_initializers (slsr_cand_t c) that block, the earliest one will be returned in WHERE. */ bb = nearest_common_dominator_for_cands (c, incr, &where); + /* If the NCD is not dominated by the block containing the + definition of the stride, we can't legally insert a + single initializer. Mark the increment as unprofitable + so we don't make any replacements. FIXME: Multiple + initializers could be placed with more analysis. */ + gimple *stride_def = SSA_NAME_DEF_STMT (c->stride); + basic_block stride_bb = gimple_bb (stride_def); + + if (stride_bb && !dominated_by_p (CDI_DOMINATORS, bb, stride_bb)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + "Initializer #%d cannot be legally placed\n", i); + incr_vec[i].cost = COST_INFINITE; + continue; + } + /* If the nominal stride has a different type than the recorded stride type, build a cast from the nominal stride to that type. */ if (!types_compatible_p (TREE_TYPE (c->stride), c->stride_type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0fab4d4702a..afaa91943ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-30 Bill Schmidt + + PR tree-optimization/81987 + * g++.dg/torture/pr81987.C: New file. + 2017-08-30 Eric Botcazou * gnat.dg/aggr22.ad[sb]: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr81987.C b/gcc/testsuite/g++.dg/torture/pr81987.C new file mode 100644 index 00000000000..4579332ad71 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr81987.C @@ -0,0 +1,61 @@ +extern short var_1; +extern const short var_3; +extern unsigned long int var_9; +extern short var_13; +extern const unsigned long int var_15; +extern const unsigned long int var_37; +extern unsigned long int var_40; +extern long long int var_47; +extern short var_48; +extern const short var_54; +extern long long int var_79; +extern long long int var_81; +extern long long int var_94; +extern long long int var_95; +extern long long int var_701; +extern unsigned long int var_786; +extern short var_788; +extern long long int var_844; + +struct struct_1 { + short member_1_2 : 15; + static long long int member_1_3; +}; + +extern struct_1 struct_obj_6; +extern struct_1 struct_obj_8; + +void foo() { + int a = var_3 <= 602154393864UL; + if (var_81 ? 0 : var_3 && var_9) + ; + else { + var_94 = 0; + if (var_3 && var_48 || var_13) { + if (var_48) + var_95 = 0; + short b((2364461588881776511UL + var_3) * (2 ? var_13 : 0) || var_1); + struct_obj_8.member_1_2 = b; + if (var_15) { + if (var_81) + if (var_47) + ; + else if (var_40) + var_701 = 0; + } else { + if (var_40) + var_79 = 0; + if (var_54) { + if (var_37) + var_786 = 0; + else + var_788 = 0; + struct_obj_6.member_1_3 = + (2364461588881776511UL + var_3) * (2 ? var_13 : 0); + } + } + if ((2364461588881776511UL + var_3) * (2 ? var_13 : 0)) + var_844 = 0; + } + } +} -- 2.30.2