aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-12-02 08:58:57 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-12-02 08:58:57 +0100
commit30fa8e9c06f511fd3a750f7649a3ee59e1721eca (patch)
treead1656efcbfedfd1f8d81bae0e1a6b0e41fa0fc2 /gcc
parentedb48cdb9f8dcc52b20f12785a1d570084597842 (diff)
downloadgcc-30fa8e9c06f511fd3a750f7649a3ee59e1721eca.zip
gcc-30fa8e9c06f511fd3a750f7649a3ee59e1721eca.tar.gz
gcc-30fa8e9c06f511fd3a750f7649a3ee59e1721eca.tar.bz2
re PR tree-optimization/83170 (ICE: Segmentation fault - during GIMPLE pass: store-merging)
PR tree-optimization/83170 PR tree-optimization/83241 * gimple-ssa-store-merging.c (imm_store_chain_info::try_coalesce_bswap): Update vuse field from gimple_vuse (ins_stmt) in case it has changed. (imm_store_chain_info::output_merged_store): Likewise. * gcc.dg/store_merging_17.c: New test. From-SVN: r255356
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-ssa-store-merging.c15
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/store_merging_17.c17
4 files changed, 40 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 40ef3d0..cdf211f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2017-12-02 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/83170
+ PR tree-optimization/83241
+ * gimple-ssa-store-merging.c
+ (imm_store_chain_info::try_coalesce_bswap): Update vuse field from
+ gimple_vuse (ins_stmt) in case it has changed.
+ (imm_store_chain_info::output_merged_store): Likewise.
+
* tree-chkp.c (chkp_compute_bounds_for_assignment): Handle
POINTER_DIFF_EXPR.
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index 61aca17..90d8c81 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -2384,6 +2384,9 @@ imm_store_chain_info::try_coalesce_bswap (merged_store_group *merged_store,
this_n.type = type;
if (!this_n.base_addr)
this_n.range = try_size / BITS_PER_UNIT;
+ else
+ /* Update vuse in case it has changed by output_merged_stores. */
+ this_n.vuse = gimple_vuse (info->ins_stmt);
unsigned int bitpos = info->bitpos - infof->bitpos;
if (!do_shift_rotate (LSHIFT_EXPR, &this_n,
BYTES_BIG_ENDIAN
@@ -3341,10 +3344,16 @@ imm_store_chain_info::output_merged_store (merged_store_group *group)
we've checked the aliasing already in try_coalesce_bswap and
we want to sink the need load into seq. So need to use new_vuse
on the load. */
- if (n->base_addr && n->vuse == NULL)
+ if (n->base_addr)
{
- n->vuse = new_vuse;
- ins_stmt = NULL;
+ if (n->vuse == NULL)
+ {
+ n->vuse = new_vuse;
+ ins_stmt = NULL;
+ }
+ else
+ /* Update vuse in case it has changed by output_merged_stores. */
+ n->vuse = gimple_vuse (ins_stmt);
}
bswap_res = bswap_replace (gsi_start (seq), ins_stmt, fndecl,
bswap_type, load_type, n, bswap);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c66f314..57ffc72 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2017-12-02 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/83170
+ PR tree-optimization/83241
+ * gcc.dg/store_merging_17.c: New test.
+
* gcc.target/i386/mpx/pointer-diff-1.c: New test.
PR c++/81212
diff --git a/gcc/testsuite/gcc.dg/store_merging_17.c b/gcc/testsuite/gcc.dg/store_merging_17.c
new file mode 100644
index 0000000..76e6b63
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/store_merging_17.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/83241 */
+/* { dg-do compile { target store_merge } } */
+/* { dg-options "-O2" } */
+
+struct S { int a; short b[32]; } e;
+struct T { volatile int c; int d; } f;
+
+void
+foo ()
+{
+ struct T g = f;
+ e.b[0] = 6;
+ e.b[1] = 6;
+ e.b[4] = g.d;
+ e.b[5] = g.d >> 16;
+ e.a = 1;
+}