loop-iv patch: Restore Blackfin hardware loops in many cases

Bernd Schmidt bernds_cb1@t-online.de
Sat Feb 24 19:52:00 GMT 2007


Yesterday I checked in a patch to disable hardware loops on the Blackfin 
with an unknown iteration count if the loop count could be 2^32.  This 
patch adds code to loop-iv.c that tries to prove that this boundary case 
can't exist.

There's a number of things that strike me as rather odd in loop-iv.c. 
determine_max_iter is the function that's used to try and place an upper 
bound on the number of iterations if it isn't constant.  If the number 
of iterations has the form (PLUS A B), it'll just drop B on the floor 
and then test whether A is a constant (impossible in canonical RTL). 
Similar for MINUS.  It seems to try to use constant terms to get bounds 
for the number of iterations, but doesn't appear to take wrapping into 
account.  I've taken this code out and replaced it by something that 
tries to improve the upper bound using simplify_using_initial_values, it 
now tries to simplify a comparison of the number of iterations with 
(MMAX - 1).  Other targets may want to try to prove a limit of (MMAX / 2 
- 1) if their loop counts are signed; I haven't tried doing this yet.

Another oddity is the fact that calculations are done in 
HOST_WIDEST_INT, despite the fact that all constants are obtained 
through CONST_INT rtx'es which limits the range to HOST_WIDE_INT.

To make sure simplify_using_initial_values can do something about the 
comparisons we now give it, I've added a number of cases to strengthen 
implies_p.

Bootstrapped and regression tested on i686-linux, and tested for a while 
now in our local Blackfin tree.  Committed as 122288.


Bernd


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: iv-maxiter.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070224/0f6cecd8/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: iv-maxiter.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070224/0f6cecd8/attachment-0001.ksh>


More information about the Gcc-patches mailing list