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. thanks, Cong > > Richard.