public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juzhe.zhong at rivai dot ai" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/113583] Main loop in 519.lbm not vectorized.
Date: Wed, 07 Feb 2024 03:39:22 +0000	[thread overview]
Message-ID: <bug-113583-4-o2A0SHUism@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113583-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
Ok. I found it even without vectorization:

GCC is worse than Clang:

https://godbolt.org/z/addr54Gc6

GCC (14 instructions inside the loop):

        fld     fa3,0(a0)
        fld     fa5,8(a0)
        fld     fa1,16(a0)
        fsub.d  fa4,ft2,fa3
        addi    a0,a0,160
        fadd.d  fa5,fa5,fa1
        addi    a1,a1,160
        addi    a5,a5,160
        fmadd.d fa4,fa4,fa2,fa3
        fnmsub.d        fa5,fa5,ft1,ft0
        fsd     fa4,-160(a1)
        fld     fa4,-152(a0)
        fadd.d  fa4,fa4,fa0
        fmadd.d fa5,fa5,fa2,fa4
        fsd     fa5,-160(a5)

Clang (12 instructions inside the loop):

        fld     fa1, -8(a0)
        fld     fa0, 0(a0)
        fld     ft0, 8(a0)
        fmadd.d fa1, fa1, fa4, fa5
        fsd     fa1, 0(a1)
        fld     fa1, 0(a0)
        fadd.d  fa0, ft0, fa0
        fmadd.d fa0, fa0, fa2, fa3
        fadd.d  fa1, fa0, fa1
        add     a4, a1, a3
        fsd     fa1, -376(a4)
        addi    a1, a1, 160
        addi    a0, a0, 160

The critical things is that:

GCC has 

        fsub.d  fa4,ft2,fa3
        fadd.d  fa5,fa5,fa1
        fmadd.d fa4,fa4,fa2,fa3
        fnmsub.d        fa5,fa5,ft1,ft0
        fadd.d  fa4,fa4,fa0
        fmadd.d fa5,fa5,fa2,fa4

6 floating-point operations.

Clang has:

        fmadd.d fa1, fa1, fa4, fa5
        fadd.d  fa0, ft0, fa0
        fmadd.d fa0, fa0, fa2, fa3
        fadd.d  fa1, fa0, fa1

Clang has 4.

2 more floating-point operations are very critical to the performance I think
since double floating-point operations are usually costly in real hardware.

  parent reply	other threads:[~2024-02-07  3:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 14:21 [Bug tree-optimization/113583] New: " rdapp at gcc dot gnu.org
2024-01-24 14:42 ` [Bug tree-optimization/113583] " juzhe.zhong at rivai dot ai
2024-01-24 14:44 ` rdapp at gcc dot gnu.org
2024-01-24 15:00 ` juzhe.zhong at rivai dot ai
2024-01-25  3:06 ` juzhe.zhong at rivai dot ai
2024-01-25  3:13 ` juzhe.zhong at rivai dot ai
2024-01-25  5:41 ` pinskia at gcc dot gnu.org
2024-01-25  9:05 ` rguenther at suse dot de
2024-01-25  9:16 ` juzhe.zhong at rivai dot ai
2024-01-25  9:34 ` rguenth at gcc dot gnu.org
2024-01-26  9:50 ` rdapp at gcc dot gnu.org
2024-01-26 10:21 ` rguenther at suse dot de
2024-02-05  6:59 ` juzhe.zhong at rivai dot ai
2024-02-07  3:39 ` juzhe.zhong at rivai dot ai [this message]
2024-02-07  7:48 ` juzhe.zhong at rivai dot ai
2024-02-07  8:04 ` rguenther at suse dot de
2024-02-07  8:08 ` juzhe.zhong at rivai dot ai
2024-02-07  8:13 ` juzhe.zhong at rivai dot ai
2024-02-07 10:24 ` rguenther at suse dot de
2024-05-13 14:17 ` rdapp at gcc dot gnu.org
2024-05-16 12:41 ` 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-113583-4-o2A0SHUism@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).