public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57186] New: implement load sinking in loops Date: Mon, 06 May 2013 14:50:00 -0000 [thread overview] Message-ID: <bug-57186-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57186 Bug #: 57186 Summary: implement load sinking in loops Classification: Unclassified Product: gcc Version: 4.9.0 URL: http://gcc.gnu.org/ml/gcc-patches/2012-10/msg00742.htm l Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: ebotcazou@gcc.gnu.org Created attachment 30040 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30040 Original implementation Even at -O3, the compiler doesn't figure out that the following loop is dumb: #define SIZE 64 int foo (int v[]) { int r; for (i = 0; i < SIZE; i++) r = v[i]; return r; } This isn't entirely unexpected, as it probably matters only for (slightly) pathological cases. The attached patch nevertheless implements a form of load sinking in loops so as to optimize these cases. It's combined with invariant motion to optimize: int foo (int v[], int a) { int r, i; for (i = 0; i < SIZE; i++) r = v[i] + a; return r; } and with store sinking to optimize: int foo (int v1[], int v2[]) { int r[SIZE]; int i, j; for (j = 0; j < SIZE; j++) for (i = 0; i < SIZE; i++) r[j] = v1[j] + v2[i]; return r[SIZE - 1]; } The optimization is enabled at -O2 in the patch for measurement purposes but, given how rarely it triggers (e.g. exactly 10 occurrences in a GCC bootstrap, compiler-only, all languages except Go), it's probably best suited to -O3. It also comes with 3 testcases.
next reply other threads:[~2013-05-06 14:50 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-05-06 14:50 ebotcazou at gcc dot gnu.org [this message] 2013-05-06 14:51 ` [Bug tree-optimization/57186] " ebotcazou at gcc dot gnu.org 2013-05-06 14:52 ` ebotcazou at gcc dot gnu.org 2013-05-06 14:52 ` ebotcazou at gcc dot gnu.org 2013-05-07 9:02 ` rguenth at gcc dot gnu.org 2021-07-26 22:09 ` 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-57186-4@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: linkBe 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).