public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bd at mail dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/42612] post-increment addressing not used
Date: Tue, 12 Jul 2022 05:21:04 +0000	[thread overview]
Message-ID: <bug-42612-4-hpDFDXXe74@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-42612-4@http.gcc.gnu.org/bugzilla/>

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

Dmitry Baksheev <bd at mail dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bd at mail dot ru

--- Comment #6 from Dmitry Baksheev <bd at mail dot ru> ---
Please consider fixing this issue. Here is another example where not using
post-increment for loops produces suboptimal code on AArch64. The code is 4x
slower than LLVM-generated code for dot-product function:

    double dotprod(std::size_t n, 
         const double* __restrict__ a, 
         const double* __restrict__ b) 
    {
        double ans = 0;
        #if __clang__
        #pragma clang loop vectorize(assume_safety)
        #else
        #pragma GCC ivdep
        #endif  
        for (std::size_t i = 0; i < n; ++i) {
            ans += a[i] * b[i];
        }
        return ans;
    }


Compile with: $(CXX) -march=armv8.2-a -O3 dp.cpp

GCC-generated loop does not have post-increment loads:
    .L3:                                                                        
        ldr d2, [x1, x3, lsl 3]                                                 
        ldr d1, [x2, x3, lsl 3]                                                 
        add x3, x3, 1                                                           
        fmadd   d0, d2, d1, d0                                                  
        cmp x0, x3                                                              
        bne .L3 

Clang emits this:
    .LBB0_4:
        ldr d1, [x10], #8                                                       
        ldr d2, [x8], #8                                                        
        subs    x9, x9, #1
        fmadd   d0, d1, d2, d0                                                  
        b.ne    .LBB0_4

  parent reply	other threads:[~2022-07-12  5:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-42612-4@http.gcc.gnu.org/bugzilla/>
2012-08-23 14:16 ` olegendo at gcc dot gnu.org
2015-05-22 13:57 ` olegendo at gcc dot gnu.org
2022-07-12  5:21 ` bd at mail dot ru [this message]
2022-07-12  5:39 ` pinskia at gcc dot gnu.org
2010-01-04 16:02 [Bug c/42612] New: [4.4/4.5] " jon at beniston dot com
2010-01-04 16:11 ` [Bug rtl-optimization/42612] " rguenth at gcc dot gnu dot org
2010-01-04 18:53 ` steven at gcc dot gnu dot org
2010-01-05 11:43 ` bonzini at gnu dot org
2010-01-05 12:13 ` jon at beniston dot com

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-42612-4-hpDFDXXe74@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).