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 target/52908] xop-mul-1:f9 miscompiled on bulldozer (-mxop)
Date: Mon, 09 Apr 2012 11:48:00 -0000	[thread overview]
Message-ID: <bug-52908-4-42hPpfkh17@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52908-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Uros Bizjak <ubizjak at gmail dot com> 2012-04-09 11:48:05 UTC ---
Created attachment 27117
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27117
Proposed patch

There are indeed two problems with XOP patterns:

a) duplication of *sse4_1_mulv2siv2di3 pattern
b) wrong order of operands in all (!!!) XOP patterns. XOP patterns consider
element 0 as MSB.

Attached patch solves this by simply removing fake xop_mulv2div2di3_{low,high}
patterns, expanding to (fixed) xop_pmacsdq{h,l} patterns directly. There is
simply no need to use vpmacsdql instead of vpmuldq. For consistency, the patch
expands to xop_pmacsdql pattern, but gcc figures out that addition of 0 is
unneeded and substitutes MAC insn with plain MUL.

Attached patch does not even try to fix other intrinsics. Someone familiar with
AMD documentation should review all these, since the documentation (43479.pdf)
is somehow inconsistent (i.e. the figure that explains VPMADCSSWD is
inconsistent with the description).

Since I don't have XOP processor, I can only eyeball the asm, in this case:

        vpxor   %xmm3, %xmm3, %xmm3
        xorl    %eax, %eax
.L3:
        vpshufd $216, c2(%rax), %xmm1
        vpshufd $216, c3(%rax), %xmm0
        vpmuldq %xmm0, %xmm1, %xmm2
        vpmacsdqh       %xmm3, %xmm0, %xmm1, %xmm0
        vmovdqa %xmm2, e1(%rax,%rax)
        vmovdqa %xmm0, e1+16(%rax,%rax)
        addq    $16, %rax
        cmpq    $2048, %rax
        jne     .L3

Please also note hoisting of constant load.


  parent reply	other threads:[~2012-04-09 11:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-08 22:48 [Bug target/52908] New: " matz at gcc dot gnu.org
2012-04-09  8:17 ` [Bug target/52908] " ubizjak at gmail dot com
2012-04-09 11:48 ` ubizjak at gmail dot com [this message]
2012-04-10 13:49 ` ubizjak at gmail dot com
2012-05-04 10:43 ` venkataramanan.kumar at amd dot com
2012-05-04 12:52 ` ubizjak at gmail dot com
2012-05-09  3:44 ` venkataramanan.kumar at amd dot com
2012-05-09 20:46 ` uros at gcc dot gnu.org
2012-05-09 20:57 ` ubizjak at gmail dot com
2012-05-10  6:22 ` ubizjak at gmail dot com
2012-06-18 15:11 ` vekumar at gcc dot gnu.org
2012-07-02 12:42 ` rguenth at gcc dot gnu.org
2024-03-17  2:33 ` sjames 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-52908-4-42hPpfkh17@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).