<s>
Zero-overhead	B-Device
looping	I-Device
is	O
a	O
feature	O
of	O
some	O
processor	O
instruction	B-General_Concept
sets	I-General_Concept
whose	O
hardware	O
can	O
repeat	O
the	O
body	O
of	O
a	O
loop	O
automatically	O
,	O
rather	O
than	O
requiring	O
software	O
instructions	O
which	O
take	O
up	O
cycles	O
(	O
and	O
therefore	O
time	O
)	O
to	O
do	O
so	O
.	O
</s>
<s>
Zero-overhead	O
loops	O
are	O
common	O
in	O
digital	B-Architecture
signal	I-Architecture
processors	I-Architecture
and	O
some	O
CISC	B-Architecture
instruction	B-General_Concept
sets	I-General_Concept
.	O
</s>
<s>
In	O
many	O
instruction	B-General_Concept
sets	I-General_Concept
,	O
a	O
loop	O
must	O
be	O
implemented	O
by	O
using	O
instructions	O
to	O
increment	O
or	O
decrement	O
a	O
counter	O
,	O
check	O
whether	O
the	O
end	O
of	O
the	O
loop	O
has	O
been	O
reached	O
,	O
and	O
if	O
not	O
jump	O
to	O
the	O
beginning	O
of	O
the	O
loop	O
so	O
it	O
can	O
be	O
repeated	O
.	O
</s>
<s>
Although	O
this	O
typically	O
only	O
represents	O
around	O
3	O
–	O
16	O
bytes	O
of	O
space	O
for	O
each	O
loop	O
,	O
even	O
that	O
small	O
amount	O
could	O
be	O
significant	O
depending	O
on	O
the	O
size	O
of	O
the	O
CPU	B-General_Concept
caches	I-General_Concept
.	O
</s>
<s>
The	O
overhead	O
of	O
such	O
a	O
loop	O
is	O
apparent	O
compared	O
to	O
a	O
completely	O
unrolled	B-Operating_System
loop	I-Operating_System
,	O
in	O
which	O
the	O
body	O
of	O
the	O
loop	O
is	O
duplicated	O
exactly	O
as	O
many	O
times	O
as	O
it	O
will	O
execute	O
.	O
</s>
<s>
However	O
,	O
the	O
duplication	O
caused	O
by	O
loop	B-Operating_System
unrolling	I-Operating_System
can	O
significantly	O
increase	O
code	O
size	O
,	O
and	O
the	O
larger	O
size	O
can	O
even	O
impact	O
execution	O
time	O
due	O
to	O
cache	O
misses	O
.	O
</s>
<s>
(	O
For	O
this	O
reason	O
,	O
it	O
's	O
common	O
to	O
only	O
partially	O
unroll	B-Operating_System
loops	I-Operating_System
,	O
such	O
as	O
transforming	O
it	O
into	O
a	O
loop	O
which	O
performs	O
the	O
work	O
of	O
four	O
iterations	O
in	O
one	O
step	O
before	O
repeating	O
.	O
</s>
<s>
Moreover	O
,	O
completely	O
unrolling	O
a	O
loop	O
is	O
only	O
possible	O
for	O
a	O
limited	O
number	O
of	O
loops	O
:	O
those	O
whose	O
number	O
of	O
iterations	O
is	O
known	O
at	O
compile	B-Application
time	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
the	O
following	O
C	O
code	O
could	O
be	O
compiled	O
and	O
optimized	O
into	O
the	O
following	O
x86	B-Language
assembly	I-Language
code	O
:	O
</s>
<s>
Processors	O
with	O
zero-overhead	B-Device
looping	I-Device
have	O
machine	O
instructions	O
and	O
registers	O
to	O
automatically	O
repeat	O
one	O
or	O
more	O
instructions	O
.	O
</s>
<s>
Depending	O
on	O
the	O
instructions	O
available	O
,	O
these	O
may	O
only	O
be	O
suitable	O
for	O
count-controlled	O
loops	O
(	O
"	O
for	O
loops	O
"	O
)	O
in	O
which	O
the	O
number	O
of	O
iterations	O
can	O
be	O
calculated	O
in	O
advance	O
,	O
or	O
only	O
for	O
condition-controlled	O
loops	O
(	O
"	O
while	O
loops	O
"	O
)	O
such	O
as	O
operations	O
on	O
null-terminated	B-Data_Structure
strings	I-Data_Structure
.	O
</s>
<s>
In	O
the	O
PIC	B-Architecture
instruction	I-Architecture
set	I-Architecture
,	O
the	O
and	O
instructions	O
implement	O
zero-overhead	O
loops	O
.	O
</s>
<s>
Blackfin	B-General_Concept
offers	O
two	O
zero-overhead	O
loops	O
.	O
</s>
<s>
The	O
x86	B-Language
assembly	I-Language
language	I-Language
prefixes	O
implement	O
zero-overhead	O
loops	O
for	O
a	O
few	O
instructions	O
(	O
namely	O
)	O
.	O
</s>
<s>
This	O
can	O
be	O
used	O
to	O
implement	O
some	O
types	O
of	O
searches	O
and	O
operations	O
on	O
null-terminated	B-Data_Structure
strings	I-Data_Structure
.	O
</s>
