http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60747
--- Comment #3 from tech <techsgin at gmail dot com> --- Created attachment 32534 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32534&action=edit Assembly of O2 WITH tree-vrp Assembly of O2 WITH tree-vrp .file "main.cpp" .text .p2align 4,,15 .globl _Z7hash_itPKci .type _Z7hash_itPKci, @function _Z7hash_itPKci: .LFB26: .cfi_startproc .cfi_personality 0x3,__gxx_personality_v0 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movl %esi, %ebp pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 movq %rdi, %rbx subq $8, %rsp .cfi_def_cfa_offset 32 call strlen cmpl $0, %eax movl %eax, %edx jle .L2 leaq 1(%rbx), %rcx leal -1(%rax), %esi leaq (%rcx,%rsi), %rsi jmp .L3 .p2align 4,,10 .p2align 3 .L11: addq $1, %rcx .L3: movsbl (%rbx), %ebx imull $777, %edx, %edx addl %ebx, %edx cmpq %rsi, %rcx movq %rcx, %rbx jne .L11 .L9: movl %edx, %eax sarl $31, %edx addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 idivl %ebp popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 movl %edx, %eax ret .L2: .cfi_restore_state jge .L12 negl %edx addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 movl %edx, %eax sarl $31, %edx idivl %ebp popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 movl %edx, %eax ret .L12: .cfi_restore_state movl %eax, %edx jmp .L9 .cfi_endproc .LFE26: .size _Z7hash_itPKci, .-_Z7hash_itPKci