public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64410] gcc 25% slower than clang 3.5 for adding complex numbers
Date: Fri, 26 Dec 2014 13:19:00 -0000	[thread overview]
Message-ID: <bug-64410-4-mTkgK0ryjG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64410-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64410

--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Conrad from comment #2)
> (In reply to Marc Glisse from comment #1)
> > 3) the ABI for complex uses 2 separate double instead of a vector of 2
> > double.
> 
> Technically yes, but in practice aren't the 2 separate doubles guaranteed to
> be consecutive in memory?

When the complex is in memory, yes. But passing a complex by value to a
function is done with 2 separate registers. And somehow that means the default
expansion for complex addition is 2 addsd, whereas the default expansion for
vector addition is addpd. Using addpd by default for complex would make some
code better (this example would hopefully be optimal without need for any
optimization) and some worse, I don't know if there are good benchmarks for
complex numbers.

Clang's use of add[ps]d seems based entirely on what is done with the result,
as can be seen on:

typedef _Complex double cd;
void f(cd&r,cd x,cd y){
  r=x+y;
}
cd f(cd&x,cd&y,cd&z){
  return x+y+z;
}

(I agree that gcc should be improved, I am not trying to defend the current
code generation. And now I'll shut up and let people who actually know the code
speak ;-)


  parent reply	other threads:[~2014-12-26 13:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-64410-4@http.gcc.gnu.org/bugzilla/>
2014-12-26 10:04 ` glisse at gcc dot gnu.org
2014-12-26 11:23 ` conradsand.arma at gmail dot com
2014-12-26 13:19 ` glisse at gcc dot gnu.org [this message]
2014-12-28  0:20 ` dje at gcc dot gnu.org
2015-01-08 13:02 ` rguenth at gcc dot gnu.org
2015-01-08 14:03 ` rguenth at gcc dot gnu.org
2015-01-08 14:06 ` rguenth at gcc dot gnu.org
2015-01-08 14:36 ` glisse at gcc dot gnu.org
2015-01-08 15:04 ` rguenth at gcc dot gnu.org
2015-01-08 15:11 ` rguenth at gcc dot gnu.org
2015-01-09 11:15 ` [Bug tree-optimization/64410] " rguenth at gcc dot gnu.org
2015-01-09 11:15 ` rguenth at gcc dot gnu.org
2015-01-20 10:06 ` ro at gcc dot gnu.org
2015-01-20 10:07 ` ro at gcc dot gnu.org
2015-01-20 11:06 ` rguenth at gcc dot gnu.org
2022-11-28 22:01 ` pinskia 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-64410-4-mTkgK0ryjG@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).