[Bug middle-end/39838] [5/6/7 regression] unoptimal code for two simple loops
hubicka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 25 11:51:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39838
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
CC| |hubicka at gcc dot gnu.org
Assignee|rakdver at gcc dot gnu.org |unassigned at gcc dot gnu.org
--- Comment #22 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Unasigning Zdenek. He is busy by his math :)
on x86 we now generate wit -Os:
test:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
pushl %edi
pushl %esi
pushl %ebx
.cfi_offset 7, -12
.cfi_offset 6, -16
.cfi_offset 3, -20
xorl %ebx, %ebx
subl $28, %esp
movl 8(%ebp), %eax
.L2:
cmpl %ebx, (%eax)
jle .L1
leal 4(,%ebx,4), %edi
xorl %esi, %esi
leal -4(%edi), %ecx
.L5:
cmpl 16(%ebp), %esi
jge .L8
movl 4(%eax), %edx
movl %eax, -32(%ebp)
incl %esi
pushl %eax
pushl %eax
movl %ecx, -28(%ebp)
pushl (%edx,%edi)
pushl (%edx,%ecx)
call func
addl $16, %esp
movl -32(%ebp), %eax
movl -28(%ebp), %ecx
jmp .L5
.L8:
incl %ebx
jmp .L2
.L1:
leal -12(%ebp), %esp
popl %ebx
.cfi_restore 3
popl %esi
.cfi_restore 6
popl %edi
.cfi_restore 7
popl %ebp
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
This is 79 bytes, while code quoted is 88 bytes.
and -O2:
test:
.LFB0:
.cfi_startproc
pushl %ebp
pushl %edi
xorl %ebp, %ebp
pushl %esi
pushl %ebx
subl $28, %esp
movl 48(%esp), %esi
movl (%esi), %ecx
testl %ecx, %ecx
jle .L1
.p2align 4,,10
.p2align 3
.L2:
movl 56(%esp), %edx
leal 1(%ebp), %eax
movl %eax, 12(%esp)
testl %edx, %edx
jle .L6
leal 0(,%eax,4), %ebx
xorl %ebp, %ebp
leal -4(%ebx), %edi
.p2align 4,,10
.p2align 3
.L4:
movl 4(%esi), %edx
subl $8, %esp
addl $1, %ebp
pushl (%edx,%ebx)
pushl (%edx,%edi)
call func
addl $16, %esp
cmpl %ebp, 56(%esp)
jne .L4
.L6:
movl 12(%esp), %ebp
cmpl %ebp, (%esi)
jg .L2
.L1:
addl $28, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.LFE0:
which is 100 bytes. So it seems that -O2 code got bigger and -Os code smaller
More information about the Gcc-bugs
mailing list