On Fri, Nov 3, 2017 at 1:39 PM, Bin Cheng <bin.ch...@arm.com> wrote: > Hi, > When fixing PR70754, I thought the issue only happens for ZERO-length chains. > Well, that's apparently not true with PR82726. > The whole story is, with chain combination/re-association, new stmts may be > created/inserted at position not dominating following uses. This happens in > two scenarios: > 1) Zero length chains, as in PR70754. > 2) Non-zero chains with multiple zero distance references. > PR82726 falls in case 2). Because zero distance references are root of the > chain, they don't inherit values from loop carried PHIs. In code generation, > we still need to be careful not inserting use before definitions. > > Previous fix to PR70754 tries to find dominance position for insertion when > combining all references. I could do the similar thing on top of that fix, > but it would be inefficient/complicated because we should only do that for > zero distance references in a non-zero length combined chain. > > This patch set fixes both PRs in the opposite way: Instead of finding > dominance > insertion position for root reference, we re-sort zero-distance references of > combined chain by their position information so that new root reference must > dominate others. This should be more efficient because we avoid function call > to stmt_dominates_stmt_p. > > This is the first patch reverting r244815 and r245689. > > Bootstrap and test on x86_64 and AArch64 in patch set. Is it OK?
Ok. Richard. > Thanks, > bin > 2017-11-02 Bin Cheng <bin.ch...@arm.com> > > PR tree-optimization/82726 > Revert > 2017-01-23 Bin Cheng <bin.ch...@arm.com> > > PR tree-optimization/70754 > * tree-predcom.c (stmt_combining_refs): New parameter INSERT_BEFORE. > (reassociate_to_the_same_stmt): New parameter INSERT_BEFORE. Insert > combined stmt before it if not NULL. > (combine_chains): Process refs reversely and compute dominance point > for root ref. > > Revert > 2017-02-23 Bin Cheng <bin.ch...@arm.com> > > PR tree-optimization/79663 > * tree-predcom.c (combine_chains): Process refs in reverse order > only for ZERO length chains, and add explaining comment.