On Fri, 21 Jun 2019, Jakub Jelinek wrote: > On Fri, Jun 21, 2019 at 06:20:35PM +0200, Richard Biener wrote: > > On June 21, 2019 5:50:45 PM GMT+02:00, Jakub Jelinek <ja...@redhat.com> > > wrote: > > >On Fri, Jun 21, 2019 at 04:17:13PM +0200, Richard Biener wrote: > > >> > > >> The following fixes a quadraticness in reassoc. > > >> > > >> Bootstrap / regtest running on x86_64-unknown-linux-gnu. > > > > > >build_and_add_sum has several other callers, don't they need a similar > > >change (or better do the gimple_set_visited (sum, true); inside of > > >build_and_add_sum)? > > > > I didn't review them and thus wanted to only affect the caller I know is > > problematic. Other callers might still Form unrelated chains? > > I don't know, what I see is that we call gimple_set_visited (, true) > in many spots we gimple_build_assign new statements so that we don't > try to process them again during the pass, and the spots where this is > not done look to me all like just forgotten thing rather than intent.
True. OTOH the callers in undistribute_ops_list look like a case where coming from A * X + B * X -> (A + B) * X we do want to re-process the A + B chain. The comment even says The alternate addition chains built are re-processed by the main reassociation algorithm which allows optimizing a * x * y + b * y * x to (a + b ) * x * y in one invocation of the reassociation pass. */ So I have committed the patch now. Richard. > There are several more spots, like force_into_ssa_name, > optimize_range_tests_to_bit_test (my fault), optimize_range_tests_cmp_bitwise > (too), optimize_range_tests_var_bound (too), attempt_builtin_copysign, > reassociate_bb. > Not sure about negate_value, repropagate_negates, those are most likely > fine, the first one is done in a separate phase so most likely doesn't want > visited to be set in there, after all that phase clears it. > And repropagate_negates is called so late that nothing cares about visited > in the pass anymore. > > Jakub > -- Richard Biener <rguent...@suse.de> SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer, Mary Higgins, Sri Rasiah; HRB 21284 (AG Nürnberg)