------- Comment #10 from spop at gcc dot gnu dot org 2010-02-09 06:00 ------- Note that subtracting 1 from the cost of the candidate IV works as well for this PR's testcase and we generate this asm with the patch:
.file "pr40886.c" .text .p2align 4,,15 .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 movl $10, %ebx .cfi_offset 3, -16 .p2align 4,,10 .p2align 3 .L2: xorl %eax, %eax call f2 subl $1, %ebx jne .L2 popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (GNU) 4.5.0 20100207 (experimental)" .section .note.GNU-stack,"",@progbits -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40886