On Fri, 16 Sep 2016, Richard Biener wrote: > On Fri, 16 Sep 2016, Bernhard Reutner-Fischer wrote: > > > On 15 September 2016 09:08:36 CEST, Richard Biener <rguent...@suse.de> > > wrote: > > > > > >Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. > > > > > > > >+ /* Likewise if we simplified to sth not queued for insertion. */ > > >+ bool found = false; > > >+ gsi = gsi_start (forced_stmts); > > >+ for (; !gsi_end_p (gsi); gsi_next (&gsi)) > > >+ { > > >+ gimple *stmt = gsi_stmt (gsi); > > >+ tree forcedname = gimple_get_lhs (stmt); > > >+ if (forcedname == folded) > > { > > >+ found = true; > > > > break;} > > > > Or do we fix up such code anyway somewhere? > > We don't -- I guess it would be an interesting transform but difficult > in this case as gimple_get_lhs might have side-effects we cannot skip. > > It might fit loop splitting which would split it "dynamically" into > a head running until we set found to true, skipping to the tail > that has the loop with omitted guard and found = true setting. > If the loop ends up with no side-effects it should end up being > removed. If not it might actually not be a desirable transform due > to code-size. > > I'll fixup the PRE code.
Bootstrapped / tested on x86_64-unknown-linux-gnu. Richard. 2016-09-19 Richard Biener <rguent...@suse.de> PR tree-optimization/77514 * tree-ssa-pre.c (create_expression_by_pieces): Optimize search for folded stmt. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 240176) +++ gcc/tree-ssa-pre.c (working copy) @@ -2881,13 +2881,16 @@ create_expression_by_pieces (basic_block } /* Likewise if we simplified to sth not queued for insertion. */ bool found = false; - gsi = gsi_start (forced_stmts); - for (; !gsi_end_p (gsi); gsi_next (&gsi)) + gsi = gsi_last (forced_stmts); + for (; !gsi_end_p (gsi); gsi_prev (&gsi)) { gimple *stmt = gsi_stmt (gsi); tree forcedname = gimple_get_lhs (stmt); if (forcedname == folded) - found = true; + { + found = true; + break; + } } if (! found) {