[ Redirect to gcc-help ] Please don't top-post, it's very confusing. Narasimha Datta wrote: > I'd love to check out the generated code on a later gcc, but > unfortunately we are not in a position to upgrade our gcc. We just > use the default gcc that came with FreeBSD 7.0. > > I'm interested in understanding why gcc generates the code the way > it does. I'm probably missing something, and I'd like to understand > that. Is counting up better than counting down in some way (add v/s > sub)? The best way to check this out it probably to look at the optimizer dumps. -fdump-tree-all gets all of them. Current gcc does this: bar: movl $127, %edx .L8: movzbl (%rsi,%rdx), %eax movb %al, (%rdi,%rdx) subq $1, %rdx cmpq $-1, %rdx jne .L8 ret which looks pretty good to me. Andrew.