public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/30907]  New: [dataflow] Bad interaction with addressing mode selection and regalloc
Date: Wed, 21 Feb 2007 10:37:00 -0000	[thread overview]
Message-ID: <bug-30907-10053@http.gcc.gnu.org/bugzilla/> (raw)

int bar (void);
void foo (int *);
static int s[10];

void foobar (int i1, int i2, int i3, int i4, int i5, int i6)
{
  int a[100];
  int i, i7;

  i7 = bar ();
  bar ();

  for (i = 0; i < 100; i++)
    a[i] = s[i1] + s[i2] + s[i3] + s[i4] + s[i5] + s[i6] + s[i7];

  foo (&a[0]);

  return;
}

If you compare mainline to dataflow branch at -O2 you can see

--- t.i.trunk   2007-02-21 11:31:09.663252586 +0100
+++ t.i.df      2007-02-21 11:31:10.548064364 +0100
@@ -37,7 +37,6 @@
        movl    s(,%rbx,4), %edx
        addl    s(,%rcx,4), %edx
        movslq  %r12d,%r12
-       leaq    16(%rsp), %rdi
        addl    s(,%r13,4), %edx
        addl    s(,%r14,4), %edx
        addl    s(,%r15,4), %edx
@@ -46,10 +45,11 @@
        addl    s(,%r12,4), %edx
        .p2align 4,,7
 .L2:
-       movl    %edx, (%rdi,%rax,4)
+       movl    %edx, 16(%rsp,%rax,4)
        addq    $1, %rax
        cmpq    $100, %rax
        jne     .L2
+       leaq    16(%rsp), %rdi
        call    foo
        addq    $424, %rsp
        popq    %rbx

that is, we are choosing a more expensive addressing mode in the loop not
noticing that 16(%rsp) can be (G)CSEd.  This makes the above loop run
33% slower on x86_64.


-- 
           Summary: [dataflow] Bad interaction with addressing mode
                    selection and regalloc
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org
GCC target triplet: x86_64-*-*


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


             reply	other threads:[~2007-02-21 10:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 10:37 rguenth at gcc dot gnu dot org [this message]
2007-02-21 15:53 ` [Bug middle-end/30907] " steven at gcc dot gnu dot org
2007-02-21 16:02 ` bonzini at gnu dot org
2007-02-22 10:20 ` bonzini at gnu dot org
2007-02-22 16:48 ` [Bug middle-end/30907] [4.3 regression] Propagation of addresses within loops pessimizes code bonzini at gnu dot org
2007-03-20  8:31 ` bonzini at gcc dot gnu dot org
2007-03-20  8:32 ` bonzini at gnu dot org
2007-04-28  4:19 ` kargl at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30907-10053@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).