Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-11 Thread Richard Biener via Gcc-patches
On Tue, 11 Jul 2023, Jan Hubicka wrote: > > > By now we did CCP and FRE so we likely optimized out most of constant > > > conditionals exposed by inline. > > > > So maybe we should simply delay re-propagation of the profile? I > > think cunrolli doesn't so much care about the profile - cunrolli

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-11 Thread Jan Hubicka via Gcc-patches
> > By now we did CCP and FRE so we likely optimized out most of constant > > conditionals exposed by inline. > > So maybe we should simply delay re-propagation of the profile? I > think cunrolli doesn't so much care about the profile - cunrolli > is (was) about abstraction removal. Jump

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-11 Thread Richard Biener via Gcc-patches
On Tue, 11 Jul 2023, Jan Hubicka wrote: > > > > What I saw most wrecking the profile is when passes turn > > if (cond) into if (0/1) leaving the CFG adjustment to CFG cleanup > > which then simply deletes one of the outgoing edges without doing > > anything to the (guessed) profile. > > Yep, I

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-11 Thread Jan Hubicka via Gcc-patches
> > What I saw most wrecking the profile is when passes turn > if (cond) into if (0/1) leaving the CFG adjustment to CFG cleanup > which then simply deletes one of the outgoing edges without doing > anything to the (guessed) profile. Yep, I agree that this is disturbing. At the cfg cleanup time

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-10 Thread Richard Biener via Gcc-patches
On Mon, 10 Jul 2023, Jan Hubicka wrote: > > On Fri, 7 Jul 2023, Jan Hubicka wrote: > > > > > > > > > > Looks good, but I wonder what we can do to at least make the > > > > multiple exit case behave reasonably? The vectorizer keeps track > > > > > > > of a "canonical" exit, would it be

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-10 Thread Richard Biener via Gcc-patches
On Mon, 10 Jul 2023, Jan Hubicka wrote: > Hi, > over weekend I found that vectorizer is missing scale_loop_profile for > epilogues. It already adjusts loop_info to set max iteraitons, so > adding it was easy. However now predicts the first loop to iterate at > most once (which is too much, I

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-10 Thread Jan Hubicka via Gcc-patches
> On Fri, 7 Jul 2023, Jan Hubicka wrote: > > > > > > > Looks good, but I wonder what we can do to at least make the > > > multiple exit case behave reasonably? The vectorizer keeps track > > > > > of a "canonical" exit, would it be possible to pass in the main > > > exit edge and use that

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-10 Thread Jan Hubicka via Gcc-patches
Hi, over weekend I found that vectorizer is missing scale_loop_profile for epilogues. It already adjusts loop_info to set max iteraitons, so adding it was easy. However now predicts the first loop to iterate at most once (which is too much, I suppose it forgets to divide by epilogue unrolling

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-10 Thread Richard Biener via Gcc-patches
On Fri, 7 Jul 2023, Jan Hubicka wrote: > > > > Looks good, but I wonder what we can do to at least make the > > multiple exit case behave reasonably? The vectorizer keeps track > > > of a "canonical" exit, would it be possible to pass in the main > > exit edge and use that instead of

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-07 Thread Jan Hubicka via Gcc-patches
> Hi Both, > > Thanks for all the reviews/patches so far  > > > > > > > Looks good, but I wonder what we can do to at least make the multiple > > > exit case behave reasonably? The vectorizer keeps track > > > > > of a "canonical" exit, would it be possible to pass in the main exit > > > edge

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-07 Thread Jan Hubicka via Gcc-patches
> > Looks good, but I wonder what we can do to at least make the > multiple exit case behave reasonably? The vectorizer keeps track > of a "canonical" exit, would it be possible to pass in the main > exit edge and use that instead of single_exit (), would other > exits then behave somewhat

RE: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-07 Thread Tamar Christina via Gcc-patches
Hi Both, Thanks for all the reviews/patches so far  > > > > Looks good, but I wonder what we can do to at least make the multiple > > exit case behave reasonably? The vectorizer keeps track > > > of a "canonical" exit, would it be possible to pass in the main exit > > edge and use that

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-06 Thread Richard Biener via Gcc-patches
On Thu, 6 Jul 2023, Jan Hubicka wrote: > Hi, > original scale_loop_profile was implemented to only handle very simple loops > produced by vectorizer at that time (basically loops with only one exit and no > subloops). It also has not been updated to new profile-count API very > carefully. >

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-06 Thread Jan Hubicka via Gcc-patches
Hi, original scale_loop_profile was implemented to only handle very simple loops produced by vectorizer at that time (basically loops with only one exit and no subloops). It also has not been updated to new profile-count API very carefully. Since I want to use it from loop peeling and unlooping, I

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-04 Thread Jan Hubicka via Gcc-patches
> On Wed, 28 Jun 2023, Tamar Christina wrote: > > > Hi All, > > > > There's an existing bug in loop frequency scaling where the if statement > > checks > > to see if there's a single exit, and records an dump file note but then > > continues. > > > > It then tries to access the null pointer,

Re: [PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-07-04 Thread Richard Biener via Gcc-patches
On Wed, 28 Jun 2023, Tamar Christina wrote: > Hi All, > > There's an existing bug in loop frequency scaling where the if statement > checks > to see if there's a single exit, and records an dump file note but then > continues. > > It then tries to access the null pointer, which of course

[PATCH 4/19]middle-end: Fix scale_loop_frequencies segfault on multiple-exits

2023-06-28 Thread Tamar Christina via Gcc-patches
Hi All, There's an existing bug in loop frequency scaling where the if statement checks to see if there's a single exit, and records an dump file note but then continues. It then tries to access the null pointer, which of course fails. For multiple loop exists it's not really clear how to scale