What is loop unfolding

Walter Bright bright at Data-IO.COM
Fri Sep 9 04:01:25 AEST 1988


In article <403 at marob.MASA.COM> samperi at marob.masa.com (Dominick Samperi) writes:
>Sorry for jumping into this discussion rather late, but could someone
>please give a brief definition of "loop unrolling."

It is the conversion of loops like:
	for (i = 0; i < 2; i++)
	    foo(i);
into:
	i = 0; foo(i);
	i = 1; foo(i);
	i = 2;
Constant propagation and dead assignment elimination is then done in an
attempt to reduce the above to:
	foo(0);
	foo(1);

Note: my optimizer does not do loop unrolling. Loop unrolling is, however,
common among Fortran optimizers.



More information about the Comp.lang.c mailing list