This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/49781] [x32] Unnecessary lea in x32 mode
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 3 Aug 2011 10:24:23 +0000
- Subject: [Bug target/49781] [x32] Unnecessary lea in x32 mode
- Auto-submitted: auto-generated
- References: <bug-49781-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49781
--- Comment #4 from Uros Bizjak <ubizjak at gmail dot com> 2011-08-03 10:24:17 UTC ---
(In reply to comment #0)
> Many lea insns can be combined with the load/store insn followed.
I have a patch that generates addr32 prefix. The result:
.file "pr49781.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
testl %edi, %edi
jle .L9
subl $1, %edi
leaq 4+heap(%rip), %rdx
xorl %eax, %eax
mov %edi, %ecx
addq $1, %rcx
.p2align 4,,10
.p2align 3
.L4:
movl %eax, (%rdx,%rax,4)
addq $1, %rax
cmpq %rcx, %rax
jne .L4
movl %edi, %ecx
.L3:
leaq 2288+heap(%rip), %rax
movl $571, %edx
jmp .L6
.p2align 4,,10
.p2align 3
.L10:
leaq heap(%rip), %rcx
movslq %edi, %rsi
subl $1, %edi
movl (%rcx,%rsi,4), %ecx
.L6:
movl 4+heap(%rip), %esi
movl %ecx, 4+heap(%rip)
movl %ecx, -4(%rax)
movl %esi, (%rax)
movl %edx, %esi
subq $8, %rax
subl $2, %edx
cmpl $1, %edi
jg .L10
movl %edi, heap_len(%rip)
movl %esi, heap_max(%rip)
ret
.L9:
movl heap(%rip), %ecx
movl $-1, %edi
jmp .L3
.cfi_endproc
.LFE0:
.size foo, .-foo
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB1:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $286, %edi
call foo@PLT
xorl %eax, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE1:
.size main, .-main
.local heap_len
.comm heap_len,4,4
.local heap_max
.comm heap_max,4,4
.local heap
.comm heap,2292,32
.ident "GCC: (GNU) 4.7.0 20110801 (experimental) [trunk revision
176998]"
.section .note.GNU-stack,"",@progbits