public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bonzini at gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/37239] New: peeling last iteration of a <= loop Date: Tue, 26 Aug 2008 11:35:00 -0000 [thread overview] Message-ID: <bug-37239-7849@http.gcc.gnu.org/bugzilla/> (raw) If the condition of the loop is tested within the loop with == or !=, it may be beneficial to peel off the final iteration of the loop by changing the condition to <. This happens in the attached benchmark's heapsort function where while ((maxIdx += maxIdx) <= last) { if (maxIdx != last && numbers[maxIdx] < numbers[maxIdx + 1]) maxIdx++; if (tmp >= numbers[maxIdx]) break; numbers[top] = numbers[maxIdx]; top = maxIdx; } can become while ((maxIdx += maxIdx) <= last) { if (numbers[maxIdx] < numbers[maxIdx + 1]) maxIdx++; if (tmp >= numbers[maxIdx]) break; numbers[top] = numbers[maxIdx]; top = maxIdx; } if (maxIdx == last && tmp < numbers[maxIdx]) { numbers[top] = numbers[maxIdx]; top = maxIdx; } enabling in turn if-conversion of the first branch. Performance of the benchmark is (-O3) basic 2.990 peeling only 2.730 if-conversion only 2.290 peel+if-convert 2.010 (faster than quicksort!!) ICC does this optimization. -- Summary: peeling last iteration of a <= loop Product: gcc Version: 4.3.2 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bonzini at gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37239
next reply other threads:[~2008-08-26 11:35 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-08-26 11:35 bonzini at gnu dot org [this message] 2008-08-26 11:37 ` [Bug tree-optimization/37239] " bonzini at gnu dot org 2008-08-27 11:59 ` rguenth at gcc dot gnu dot org 2008-08-27 12:09 ` bonzini at gnu dot org 2008-08-29 4:28 ` pinskia at gcc dot gnu dot 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-37239-7849@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).