[PATCH] Fix recent store-merging ICE (PR tree-optimization/82838)
Jakub Jelinek
jakub@redhat.com
Mon Nov 6 06:32:00 GMT 2017
Hi!
force_gimple_operand_1 clears the *seq first and then adds statements
there if any are needed. So calling force_gimple_operand_1 twice on the
same seq is throwing away the earlier statements if any, rather than
appending new statements to those.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2017-11-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/82838
* gimple-ssa-store-merging.c
(imm_store_chain_info::output_merged_store): Call force_gimple_operand_1
on a separate gimple_seq which is then appended to seq.
* gcc.c-torture/compile/pr82838.c: New test.
--- gcc/gimple-ssa-store-merging.c.jj 2017-11-04 19:59:28.000000000 +0100
+++ gcc/gimple-ssa-store-merging.c 2017-11-04 22:59:07.410232483 +0100
@@ -1670,10 +1670,14 @@ imm_store_chain_info::output_merged_stor
else if (operand_equal_p (base_addr, op.base_addr, 0))
load_addr[j] = addr;
else
- load_addr[j]
- = force_gimple_operand_1 (unshare_expr (op.base_addr),
- &seq, is_gimple_mem_ref_addr,
- NULL_TREE);
+ {
+ gimple_seq this_seq;
+ load_addr[j]
+ = force_gimple_operand_1 (unshare_expr (op.base_addr),
+ &this_seq, is_gimple_mem_ref_addr,
+ NULL_TREE);
+ gimple_seq_add_seq_without_update (&seq, this_seq);
+ }
}
FOR_EACH_VEC_ELT (split_stores, i, split_store)
--- gcc/testsuite/gcc.c-torture/compile/pr82838.c.jj 2017-11-04 23:02:09.522012666 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr82838.c 2017-11-04 23:01:54.000000000 +0100
@@ -0,0 +1,12 @@
+/* PR tree-optimization/82838 */
+
+struct S { unsigned short a, b, c; };
+struct S f[10];
+
+void
+foo (int e)
+{
+ struct S *x;
+ f[e].b = x[e].a;
+ f[e].c = x[e].b;
+}
Jakub
More information about the Gcc-patches
mailing list