Loop Unrolling Transformation: Difference between revisions

Jump to navigation Jump to search
Line 63: Line 63:
|-
|-
|<syntaxhighlight lang="c">
|<syntaxhighlight lang="c">
/* The following code tests loop unroll transformation applied to a for loop: */ 
#pragma EMX_TRANSFORMATION LoopUnroll { "unrollfactor": 3 }
for (int i = 1; i < n; i++) {
printf("%d\n", i);
}


int main(void) {
    int i;
    int a[4];
    #pragma EMX_TRANSFORMATION LoopUnroll { ”unrollfactor”: 4}
    for (i = 0; i < 4; i++) {
        a[i] = i;
    }
    return 0;
}
</syntaxhighlight>
</syntaxhighlight>
|<syntaxhighlight lang="c">
|<syntaxhighlight lang="c">
/* The generated code includes all four iterations of the loop transformed into four separate statements.
for (i = 1; (i + 2) < n; i = i + 3) {
* The loop unrolling is full and the loop is removed.
printf("%d\n", i);
*/
printf("%d\n", i + 1);
printf("%d\n", i + 2);
}


int main(void) {
for (; i < n; i = i + 1) {
    int i;
printf("%d\n", i);
    int a[4];
    i = 0;
    {
        a[i] = i;
    } {
        a[i + 1 * 1] = i + 1 * 1;
    } {
        a[i + 1 * 2] = i + 1 * 2;
    } {
        a[i + 1 * 3] = i + 1 * 3;
    }
    return 0;
}
}
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Bots, Bureaucrats, Interface administrators, smwadministrator, smwcurator, smweditor, Administrators
2,557

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu