optimization/10624: unroll-loops can't unroll nested constant loops

thome@lix.polytechnique.fr thome@lix.polytechnique.fr
Mon May 5 09:36:00 GMT 2003


>Number:         10624
>Category:       optimization
>Synopsis:       unroll-loops can't unroll nested constant loops
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon May 05 09:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     thome@lix.polytechnique.fr
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
#include <stdio.h>

/*
 * GCC is apparently unable to understand that this loop can be unrolled.
 *
 * That's a pity, as we would really want to avoid jumps (of course,
 * replace printf by some more critical code. I've got an example of such
 * code where ``manual'' unrolling wins 25%, and I guess that much larger
 * gaps can be obtained easily...)
 *
 * It is not a matter of MAX_UNROLLED_INSNS hitting the bound. The inner
 * loop is constant when the outer is expanded, but I guess unroll-loops
 * makes 1 pass only.
 *
 * Would it be prohibitive to handle such cases that might require
 * several passes for proper unrolling ?
 *
 * gcc -O3 -funroll-loops -S unroll_me.c
 */
void unroll_me()
{
        const int n = 3;
        int i, j;

        for(i=0;i<n;i++) {
                for(j=0;j<i;j++) {
                        printf("%d, %d\n",i,j);
                }
        }
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list