public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guojiufu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/88767] 'unroll and jam' not optimizing some loops
Date: Thu, 17 Dec 2020 02:58:02 +0000	[thread overview]
Message-ID: <bug-88767-4-n0f8q8q9Vg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-88767-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #13 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Hi Richard,

As checking the changed code as in comment 9, it seems there is another
opportunity to improve the performance:  By improving locality of array A
usage.

Unroll and jam loop1 into loop4 (or unroll and jam loop1 into loop3 after
loop2/loop4 are unrolled completely), this would reduce memory access by
reusing elements of array A. 

It seems not hard to implement this improvement from the source code aspect (as
the example code shown in comment 9). 
While I'm thinking about how to implement this in GCC.

Some concerns are here.  It is not a `perfect nest` for these loops: there are
stmts/instructions that belong to the outer loop (loop1) but outside the inner
loop(loop4). 
And even delete loop2 (or distribute loop2 out) and unroll loop4, 'store to
array C: C[(l_n*10)+l_m] +=xx` is moved out of the inner loop (loop3), but
still inside the outer loop(loop1).  This is not in favor of 'unroll and jam'.

Thanks for any comments!

BR. 
Jiufu Guo

  parent reply	other threads:[~2020-12-17  2:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-88767-4@http.gcc.gnu.org/bugzilla/>
2020-12-16  5:57 ` guojiufu at gcc dot gnu.org
2020-12-16  6:04 ` guojiufu at gcc dot gnu.org
2020-12-16  9:14 ` rguenth at gcc dot gnu.org
2020-12-17  2:58 ` guojiufu at gcc dot gnu.org [this message]
2021-01-04  9:02 ` rguenth at gcc dot gnu.org
2021-01-08  5:34 ` guojiufu 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-88767-4-n0f8q8q9Vg@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).