This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FORCING GCC TO UNROLL LOOPS


I looked into the code and saw the part that assumes power of two for
unrolling:

  niter = expand_simple_binop (desc->mode, AND,
			       niter,
			       GEN_INT (max_unroll),
			       NULL_RTX, 0, OPTAB_LIB_WIDEN);

You had earlier mentioned that i need to change this code. I tried to
understand this code but could not make head or tail out of it. Can you
please tell me how to change this code so that i can force gcc to unroll
runtime loops by all factors. Also, is there any need to change the code for
constant loops so that gcc unrolls it by all factors?


Ian Lance Taylor-3 wrote:
> 
> dibstar <dibyam4@gmail.com> writes:
> 
>> I am using gcc 4.4.5. I have looked into unroll_loop_runtime_iterations.
>> Can
>> you please tell me how to change this code to enable unrolling by all
>> factors?
> 
> I think I already did.  You have to tell me which part of the
> explanation you didn't understand.
> 
> Ian
> 
>> Ian Lance Taylor-3 wrote:
>>> 
>>> dibstar <dibyam4@gmail.com> writes:
>>> 
>>>>         I wish to force gcc to unroll both the constant time iterating
>>>> loops
>>>> and the runtime iterating loops as outlined in loop-unroll.c. I
>>>> modified
>>>> the
>>>> loop-unroll.c to place all unrolling decisions in the function
>>>> decide-unroll-and-peel. I also made gcc interact with the user by
>>>> asking
>>>> the
>>>> user the function name that which contains the desired loop and the
>>>> loop
>>>> number and the desired unroll factor. This seems to be fine for
>>>> unrolling
>>>> constant time iterating loops, i.e. i am able to unroll these loops by
>>>> all
>>>> factors from 1 to 8. However, for runtime loops, i get a segmentation
>>>> fault.
>>>> I analysed the code and found that gcc assumes that the unroll factor
>>>> is
>>>> a
>>>> power of 2 for runtime loops. I wish to change this and force gcc to
>>>> unroll
>>>> a particular loop by all factors from 1 to 8. How can I do this?
>>> 
>>> What version of gcc?
>>> 
>>> I assume you mean decide_unrolling_and_peeling rather than
>>> decide-unroll-and-peel.
>>> 
>>> I agree that the code assumes that the unroll factor is a power of 2.
>>> If you want to use a different factor, you will have to change the code.
>>> Are you asking how to do that?  Look in unroll_loop_runtime_iterations.
>>> It uses AND; as the comment explains, that only works because it is
>>> unrolling by a power of 2.  If you want something else to work, you will
>>> need to change that.
>>> 
>>> Ian
>>> 
>>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/FORCING-GCC-TO-UNROLL-LOOPS-tp33455948p33469509.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]