public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug other/47167] Performance regression in numerical code
Date: Wed, 05 Jan 2011 19:50:00 -0000	[thread overview]
Message-ID: <bug-47167-4-3eYMURet6z@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47167-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Uros Bizjak <ubizjak at gmail dot com> 2011-01-05 19:30:49 UTC ---
> this could be the reason for slowdown.

Hm, not really.

But, by changing the generated assembly around loop entry:

$ diff -u testcase2.s testcase2_.s
--- testcase2.s    2011-01-05 20:21:01.492919294 +0100
+++ testcase2_.s    2011-01-05 20:22:23.616577277 +0100
@@ -1678,6 +1678,7 @@
     addq    %r15, %rdx
     addq    $1, %rdi
     salq    $5, %rdi
+    movapd    %xmm10, %xmm0
     jmp    .L143
     .p2align 4,,10
     .p2align 3
@@ -1687,7 +1688,7 @@
     mulpd    %xmm2, %xmm6
     movapd    %xmm3, %xmm2
     movapd    %xmm10, (%rsi,%rcx)
-    mulpd    %xmm10, %xmm2
+    mulpd    %xmm0, %xmm2
     movsd    (%rdx), %xmm0
     movsd    8(%rdx), %xmm1
     subpd    %xmm6, %xmm2

The slowdown is magically fixed:

$ gcc -lm testcase2_.s
$ time ./a.out

real    0m4.041s
user    0m4.034s
sys    0m0.003s

versus:

$ gcc -lm testcase2.s
$ time ./a.out

real    0m4.239s
user    0m4.234s
sys    0m0.001s

The important change is the change of %xmm10 -> %xmm0 in the mulpd instruction.
The functionality of the test didn't change due to existing "movapd    %xmm0,
%xmm10" at the top of the loop and added extra "movapd    %xmm10, %xmm0" before
the loop.

This all happens on SnB, the code is generated with -O2 only.

H.J., any ideas?


  parent reply	other threads:[~2011-01-05 19:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-04 14:45 [Bug other/47167] New: " martin@mpa-garching.mpg.de
2011-01-05 14:46 ` [Bug other/47167] " martin@mpa-garching.mpg.de
2011-01-05 17:38 ` ubizjak at gmail dot com
2011-01-05 19:50 ` ubizjak at gmail dot com [this message]
2011-01-05 20:09 ` ubizjak at gmail dot com
2011-01-05 22:14 ` hjl.tools at gmail dot com
2011-01-06  9:33 ` ubizjak at gmail dot com
2011-01-19 15:37 ` martin@mpa-garching.mpg.de
2011-01-19 16:32 ` rguenth at gcc dot gnu.org
2011-01-19 18:10 ` martin@mpa-garching.mpg.de
2011-01-20 10:41 ` rguenth at gcc dot gnu.org
2011-01-20 10:42 ` rguenth at gcc dot gnu.org
2011-01-20 10:43 ` rguenth at gcc dot gnu.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-47167-4-3eYMURet6z@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).