On Mon, 6 Nov 2017, Jakub Jelinek wrote: > 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?
Ok. Richard. > 2017-11-06 Jakub Jelinek <ja...@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 > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)