------- Comment #3 from changpeng dot fang at amd dot com 2010-06-04 23:29 ------- (In reply to comment #2) > Interesting! What's the difference between 17 and 18? > ------------ > int main() > { > double i; > for(i=0; i<18; i+=1); /* gcc -O3, empty loop not removed */ > }
The funny thing occurs in gcc 4, not gcc 6: .file "empty.c" .text .p2align 4,,15 .globl main .type main, @function main: .LFB0: .cfi_startproc xorl %eax, %eax .p2align 4,,10 .p2align 3 .L2: addl $1, %eax cmpl $18, %eax jne .L2 rep ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1" .section .note.GNU-stack,"",@progbits -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43529