On Fri, 2 Jun 2017, Jakub Jelinek wrote: > Hi! > > As has been mentioned earlier, when the doloop code uses the expander after > expansion, we need to unshare stuff because the expander relies on unsharing > being done after it. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok. Richard. > 2017-06-02 Jakub Jelinek <ja...@redhat.com> > > PR rtl-optimization/80903 > * loop-doloop.c (add_test): Unshare sequence. > > * gcc.dg/pr80903.c: New test. > > --- gcc/loop-doloop.c.jj 2017-03-24 14:36:35.000000000 +0100 > +++ gcc/loop-doloop.c 2017-05-29 12:40:39.062107631 +0200 > @@ -367,6 +367,7 @@ add_test (rtx cond, edge *e, basic_block > } > > seq = get_insns (); > + unshare_all_rtl_in_chain (seq); > end_sequence (); > > /* There always is at least the jump insn in the sequence. */ > --- gcc/testsuite/gcc.dg/pr80903.c.jj 2017-05-29 12:40:27.988242239 +0200 > +++ gcc/testsuite/gcc.dg/pr80903.c 2017-05-29 12:37:39.000000000 +0200 > @@ -0,0 +1,34 @@ > +/* PR rtl-optimization/80903 */ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -funroll-loops" } */ > + > +short int a; > + > +void > +foo (int x, short int y, short int z) > +{ > + if (y != 0) > + { > + const short int b = 37; > + y = 0; > + while (y < b) > + { > + while (y < b) > + { > + lab: > + ++y; > + } > + for (y = 0; y < b - 1; ++y) > + ; > + if (z != 0) > + { > + --a; > + y *= a; > + } > + z = x; > + } > + x = 0; > + } > + > + goto lab; > +} > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)