public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jiangning.liu at amperecomputing dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/98598] Missed opportunity to optimize dependent loads in loops
Date: Fri, 08 Jan 2021 09:15:37 +0000	[thread overview]
Message-ID: <bug-98598-4-rZCWJKOsYd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98598-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Jiangning Liu <jiangning.liu at amperecomputing dot com> ---
Loop distribution can only handle very simple case. If the inner loop has
complicated control flow and other memory accesses with loop-carried
dependence, it would be hard to handle it. For example,

int foo (int n, int m, A *pa) {
  int sum;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      sum += pa[j].pb->pc->val;  // each value is repeatedly loaded "n" times
      sum = sum % 7;
    }
    sum = sum % 13;
  }

  return sum;
}

Alternatively, we can detect "invariant" dependent memory loads for the nested
loops with alias conflict checked. If the outer loop is hot enough, we could
have a chance to "hoist" them to create cache.

As for temp storage, is it a gcc's rule of thumb not to introduce temp storage
on heap, or it is just gcc doesn't have it yet and we want to have it?

  parent reply	other threads:[~2021-01-08  9:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  8:24 [Bug tree-optimization/98598] New: " hliu at amperecomputing dot com
2021-01-08  8:43 ` [Bug tree-optimization/98598] " rguenth at gcc dot gnu.org
2021-01-08  9:15 ` jiangning.liu at amperecomputing dot com [this message]
2021-01-08  9:55 ` rguenther at suse dot de
2021-01-08 11:57 ` amker at gcc dot gnu.org
2021-01-09  3:17 ` jiangning.liu at amperecomputing dot com
2021-01-09  9:48 ` rguenther at suse dot de
2021-01-09 10:42 ` jiangning.liu at amperecomputing dot com
2021-01-11  7:17 ` rguenther at suse dot de
2021-01-11  9:16 ` crazylht at gmail dot com
2021-01-11 11:41 ` jiangning.liu at amperecomputing dot com
2021-01-11 12:05 ` jiangning.liu at amperecomputing dot com
2021-01-14 22:53 ` jiangning.liu at amperecomputing dot com
2021-12-23  9:49 ` pinskia 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-98598-4-rZCWJKOsYd@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).