On Mon, 17 Mar 2014, Cong Hou wrote:

> On Mon, Mar 17, 2014 at 6:44 AM, Richard Biener <rguent...@suse.de> wrote:
> > On Fri, 14 Mar 2014, Cong Hou wrote:
> >
> >> On Fri, Mar 14, 2014 at 12:58 AM, Richard Biener <rguent...@suse.de> wrote:
> >> > On Fri, 14 Mar 2014, Jakub Jelinek wrote:
> >> >
> >> >> On Fri, Mar 14, 2014 at 08:52:07AM +0100, Richard Biener wrote:
> >> >> > > Consider this fact and if there are alias checks, we can safely 
> >> >> > > remove
> >> >> > > the epilogue if the maximum trip count of the loop is less than or
> >> >> > > equal to the calculated threshold.
> >> >> >
> >> >> > You have to consider n % vf != 0, so an argument on only maximum
> >> >> > trip count or threshold cannot work.
> >> >>
> >> >> Well, if you only check if maximum trip count is <= vf and you know
> >> >> that for n < vf the vectorized loop + it's epilogue path will not be 
> >> >> taken,
> >> >> then perhaps you could, but it is a very special case.
> >> >> Now, the question is when we are guaranteed we enter the scalar 
> >> >> versioned
> >> >> loop instead for n < vf, is that in case of versioning for alias or
> >> >> versioning for alignment?
> >> >
> >> > I think neither - I have plans to do the cost model check together
> >> > with the versioning condition but didn't get around to implement that.
> >> > That would allow stronger max bounds for the epilogue loop.
> >>
> >> In vect_transform_loop(), check_profitability will be set to true if
> >> th >= VF-1 and the number of iteration is unknown (we only consider
> >> unknown trip count here), where th is calculated based on the
> >> parameter PARAM_MIN_VECT_LOOP_BOUND and cost model, with the minimum
> >> value VF-1. If the loop needs to be versioned, then
> >> check_profitability with true value will be passed to
> >> vect_loop_versioning(), in which an enhanced loop bound check
> >> (considering cost) will be built. So I think if the loop is versioned
> >> and n < VF, then we must enter the scalar version, and in this case
> >> removing epilogue should be safe when the maximum trip count <= th+1.
> >
> > You mean exactly in the case where the profitability check ensures
> > that n % vf == 0?  Thus effectively if n == maximum trip count?
> > That's quite a special case, no?
> 
> 
> Yes, it is a special case. But it is in this special case that those
> warnings are thrown out. Also, I think declaring an array with VF*N as
> length is not unusual.

Ok, but then for the patch compute the cost model threshold once
in vect_analyze_loop_2 and store it in a new
LOOP_VINFO_COST_MODEL_THRESHOLD.  Also you have to check
the return value from max_stmt_executions_int as that may return
-1 if the number cannot be computed (or isn't representable in
a HOST_WIDE_INT).  You also should check for
LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT which should have the
same effect on the cost model check.

The existing condition is already complicated enough - adding new
stuff warrants comments before the (sub-)checks.

Richard.

Reply via email to