cgccpragmaunroll

Tell gcc to specifically unroll a loop


How can I tell GCC to unroll a particular loop? I have used the CUDA SDK where loops can be unrolled manually using #pragma unroll. Is there a similar feature for gcc? I googled a bit but could not find anything.


Solution

  • GCC gives you a few different ways of handling this:

    Note: I'm not sure how good GCC is at unrolling reverse-iterated loops (I did it to get Markdown to play nice with my code). The examples should compile fine, though.