public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49781] New: Unnecessary lea in x32 mode
@ 2011-07-18 20:54 hjl.tools at gmail dot com
  2011-07-19  6:46 ` [Bug target/49781] " ubizjak at gmail dot com
                   ` (47 more replies)
  0 siblings, 48 replies; 49+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-18 20:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49781

           Summary: Unnecessary lea in x32 mode
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hjl.tools@gmail.com


[hjl@gnu-6 pr47383]$ cat x.i
static int heap[2*(256 +1+29)+1];
static int heap_len;
static int heap_max;
void 
__attribute__ ((noinline))
foo (int elems)
{
  int n, m;
  int max_code = -1;
  int node = elems;
  heap_len = 0, heap_max = (2*(256 +1+29)+1);
  for (n = 0; n < elems; n++)
    heap[++heap_len] = max_code = n;
  do {
    n = heap[1];
    heap[1] = heap[heap_len--];
    m = heap[1];
    heap[--heap_max] = n;
    heap[--heap_max] = m;
  } while (heap_len >= 2);
}

int
main ()
{
  foo (286);
  return 0;
}
[hjl@gnu-6 pr47383]$ make x.s
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o x.s -mx32 -O2 -fPIC 
x.i
[hjl@gnu-6 pr47383]$ cat x.s
    .file    "x.i"
    .text
    .p2align 4,,15
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    xorl    %eax, %eax
    testl    %edi, %edi
    pushq    %rbx
    .cfi_def_cfa_offset 16
    .cfi_offset 3, -16
    leal    4+heap(%rip), %ecx
    jle    .L10
    .p2align 4,,10
    .p2align 3
.L7:
    leal    (%rcx,%rax,4), %edx
    movl    %eax, (%rdx)
    addl    $1, %eax
    cmpl    %edi, %eax
    jne    .L7
    leal    -1(%rdi), %ecx
.L3:
    leal    -1(%rdi), %eax
    movl    $573, %esi
    leal    2296+heap(%rip), %r11d
    leal    2292+heap(%rip), %r10d
    leal    heap(%rip), %ebx
    jmp    .L5
    .p2align 4,,10
    .p2align 3
.L11:
    leal    (%rbx,%rax,4), %edx
    subl    $1, %eax
    movl    (%rdx), %ecx
.L5:
    movl    %eax, %edx
    movl    4+heap(%rip), %r9d
    subl    $2, %esi
    subl    %edi, %edx
    movl    %ecx, 4+heap(%rip)
    sall    $3, %edx
    leal    (%r11,%rdx), %r8d
    addl    %r10d, %edx
    cmpl    $1, %eax
    movl    %r9d, (%r8)
    movl    %ecx, (%rdx)
    jg    .L11
    movl    %eax, heap_len(%rip)
    movl    %esi, heap_max(%rip)
    popq    %rbx
    .cfi_remember_state
    .cfi_def_cfa_offset 8
    ret
.L10:
    .cfi_restore_state
    movl    heap(%rip), %ecx
    xorl    %edi, %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 20110718 (experimental)"
    .section    .note.GNU-stack,"",@progbits
[hjl@gnu-6 pr47383]$ 

Many lea insns can be combined with the load/store insn followed.


^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2011-08-12  6:31 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-18 20:54 [Bug target/49781] New: Unnecessary lea in x32 mode hjl.tools at gmail dot com
2011-07-19  6:46 ` [Bug target/49781] " ubizjak at gmail dot com
2011-07-19 13:07 ` hjl.tools at gmail dot com
2011-08-03  7:00 ` [Bug target/49781] [x32] " ubizjak at gmail dot com
2011-08-03 10:24 ` ubizjak at gmail dot com
2011-08-03 10:28 ` ubizjak at gmail dot com
2011-08-03 10:31 ` ubizjak at gmail dot com
2011-08-03 13:27 ` hjl.tools at gmail dot com
2011-08-03 14:10 ` hjl.tools at gmail dot com
2011-08-03 14:45 ` ubizjak at gmail dot com
2011-08-03 15:01 ` ubizjak at gmail dot com
2011-08-03 15:45 ` hjl.tools at gmail dot com
2011-08-03 16:09 ` ubizjak at gmail dot com
2011-08-03 16:19 ` hjl.tools at gmail dot com
2011-08-03 16:47 ` hjl.tools at gmail dot com
2011-08-03 16:49 ` hjl.tools at gmail dot com
2011-08-04 18:50 ` ubizjak at gmail dot com
2011-08-04 18:53 ` ubizjak at gmail dot com
2011-08-04 19:40 ` hjl.tools at gmail dot com
2011-08-04 20:00 ` ubizjak at gmail dot com
2011-08-04 20:10 ` ubizjak at gmail dot com
2011-08-04 21:00 ` hjl.tools at gmail dot com
2011-08-04 21:03 ` hjl.tools at gmail dot com
2011-08-04 22:25 ` hjl.tools at gmail dot com
2011-08-05  6:26 ` ubizjak at gmail dot com
2011-08-05 19:02 ` ubizjak at gmail dot com
2011-08-05 21:58 ` hjl.tools at gmail dot com
2011-08-05 22:02 ` ubizjak at gmail dot com
2011-08-07  7:31 ` ubizjak at gmail dot com
2011-08-07 12:54 ` ubizjak at gmail dot com
2011-08-07 13:09 ` ubizjak at gmail dot com
2011-08-07 13:50 ` ubizjak at gmail dot com
2011-08-07 20:24 ` hjl.tools at gmail dot com
2011-08-08 13:35 ` hjl.tools at gmail dot com
2011-08-08 14:59 ` uros at gcc dot gnu.org
2011-08-08 16:29 ` hjl.tools at gmail dot com
2011-08-08 16:33 ` hjl at gcc dot gnu.org
2011-08-08 17:17 ` ubizjak at gmail dot com
2011-08-09  7:39 ` uros at gcc dot gnu.org
2011-08-09 18:38 ` ubizjak at gmail dot com
2011-08-09 18:50 ` hjl.tools at gmail dot com
2011-08-09 19:00 ` hjl.tools at gmail dot com
2011-08-09 21:22 ` hjl.tools at gmail dot com
2011-08-10 18:19 ` ubizjak at gmail dot com
2011-08-10 18:30 ` ubizjak at gmail dot com
2011-08-10 18:44 ` hjl.tools at gmail dot com
2011-08-11 12:55 ` hjl.tools at gmail dot com
2011-08-11 20:03 ` uros at gcc dot gnu.org
2011-08-12  6:31 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).