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 target/39678] std::transform is incorrect with std::multiples and bind2nd for complex<float>
Date: Tue, 07 Apr 2009 15:45:00 -0000	[thread overview]
Message-ID: <20090407154500.6974.qmail@sourceware.org> (raw)
In-Reply-To: <bug-39678-15185@http.gcc.gnu.org/bugzilla/>



------- Comment #9 from rguenth at gcc dot gnu dot org  2009-04-07 15:44 -------
Wait - it's ok.

    class binder2nd
    : public unary_function<typename _Operation::first_argument_type,
       typename _Operation::result_type>
    {
    protected:
      _Operation op;
      typename _Operation::second_argument_type value;

_Operation is probably empty, so there are 4 bytes padding and the struct
is returned in a xmm0

(gdb) p $xmm0
$5 = {v4_float = {-9.04046813e+33, 4, 0, 0}

but we access the result like

        call   
_ZSt7bind2ndISt10multipliesISt7complexIfEES2_ESt9binder2ndIT_ERKS5_RKT0_
        movl    72(%rsp), %edx
        movq    %xmm0, 8(%rsp)
        movq    8(%rsp), %rax
        movl    %edx, 88(%rsp)
        movq    %rax, 80(%rsp)
        movss   88(%rsp), %xmm5
        movq    %rax, 64(%rsp)
        movss   84(%rsp), %xmm4
        movq    %rax, 96(%rsp)
        movl    %edx, 104(%rsp)
        .loc 5 1144 0
        movaps  %xmm4, %xmm0
        movaps  %xmm5, %xmm1
        movss   4(%rbx), %xmm3
        movss   (%rbx), %xmm2
        movss   %xmm4, 32(%rsp)
        movss   %xmm5, 16(%rsp)
        call    __mulsc3
        movq    %xmm0, 56(%rsp)
        movl    56(%rsp), %eax
        movl    60(%rsp), %edx


so you can see we simply use the lower 8 bytes of %xmm0 only ...
(supposedly thinking that the other half got loaded to %edx).

It's already broken at expansion:

(call_insn 67 66 68 11 t.C:13 (set (parallel:BLK [
                (expr_list:REG_DEP_TRUE (reg:DI 21 xmm0)
                    (const_int 0 [0x0]))
            ])
        (call (mem:QI (symbol_ref/i:DI
("_ZSt7bind2ndISt10multipliesISt7complexIfEES2_ESt9binder2ndIT_ERKS5_RKT0_")
[flags 0x1] <function_decl 0x7ffff4887d00 bind2nd>) [0 S1 A8])
            (const_int 0 [0x0]))) -1 (expr_list:REG_EH_REGION (const_int 0
[0x0])
        (nil))
    (expr_list:REG_DEP_TRUE (use (reg:DI 5 di))
        (expr_list:REG_DEP_TRUE (use (reg:DI 4 si))
            (nil))))

(insn 68 67 69 11 t.C:13 (set (reg:DI 92)
        (reg:DI 21 xmm0)) -1 (nil))


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|same                        |x86_64-*-*


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


  parent reply	other threads:[~2009-04-07 15:45 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07 13:50 [Bug c++/39678] New: " diepen at astron dot nl
2009-04-07 13:54 ` [Bug c++/39678] " paolo dot carlini at oracle dot com
2009-04-07 14:03 ` diepen at astron dot nl
2009-04-07 14:18 ` paolo dot carlini at oracle dot com
2009-04-07 14:24 ` paolo dot carlini at oracle dot com
2009-04-07 14:51 ` [Bug target/39678] " rguenth at gcc dot gnu dot org
2009-04-07 15:04 ` paolo dot carlini at oracle dot com
2009-04-07 15:29 ` rguenth at gcc dot gnu dot org
2009-04-07 15:33 ` paolo dot carlini at oracle dot com
2009-04-07 15:45 ` rguenth at gcc dot gnu dot org [this message]
2009-04-07 15:45 ` rguenth at gcc dot gnu dot org
2009-04-07 15:47 ` rguenth at gcc dot gnu dot org
2009-04-07 15:48 ` paolo dot carlini at oracle dot com
2009-04-07 15:57 ` rguenth at gcc dot gnu dot org
2009-04-07 16:05 ` rguenth at gcc dot gnu dot org
2009-04-07 16:05 ` rguenth at gcc dot gnu dot org
2009-04-07 16:24 ` paolo dot carlini at oracle dot com
2009-04-07 16:45 ` paolo dot carlini at oracle dot com
2009-04-07 19:01 ` paolo dot carlini at oracle dot com
2009-04-07 20:47 ` paolo dot carlini at oracle dot com
2009-04-07 22:04 ` paolo dot carlini at oracle dot com
2009-04-08  8:40 ` rguenth at gcc dot gnu dot org
2009-04-08  9:11 ` paolo dot carlini at oracle dot com
2009-04-08 23:42 ` [Bug target/39678] C++ empty struct is passed incorrectly hjl dot tools at gmail dot com
2009-04-09  1:16 ` [Bug target/39678] complex type isn't passed correctly hjl dot tools at gmail dot com
2009-04-09  1:17 ` hjl dot tools at gmail dot com
2009-04-09  1:18 ` hjl dot tools at gmail dot com
2009-04-09  4:43 ` hjl dot tools at gmail dot com
2009-04-09  7:58 ` rguenther at suse dot de
2009-04-09 14:18 ` hjl dot tools at gmail dot com
2009-04-09 15:09 ` diepen at astron dot nl
2009-04-09 15:36 ` hjl dot tools at gmail dot com
2009-04-09 15:46 ` rguenth at gcc dot gnu dot org
2009-04-09 22:59 ` hjl at gcc dot gnu dot org
2009-04-14 20:28 ` hjl at gcc dot gnu dot org
2009-04-28 23:44 ` pinskia 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=20090407154500.6974.qmail@sourceware.org \
    --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).