public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Maxim Kuvyrkov <maxim@codesourcery.com>
To: naga raj <gnuuser.raj@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: loop-unrolling in gcc-4.6.2
Date: Mon, 26 Nov 2012 06:43:00 -0000	[thread overview]
Message-ID: <06230AFE-EC8F-4F19-BFCF-E7D1D6DF6CBE@codesourcery.com> (raw)
In-Reply-To: <CAKuVEhDXXA24veEaWNhek4v1N2ZYsw31dQ1KP8+BLcMudhZCEA@mail.gmail.com>

On 24/11/2012, at 4:02 AM, naga raj wrote:

> Hi,
> 
>   I am using Gcc-4.6.2 compiler ported to an embedded target.
>   I am running a CoreMark benchmark code using -funroll-loops option
> Surprisingly I found that loops are not unrolled.
>   But the same code when compiled with older toolchain version(with
> Gcc-4.1.2) is generating loop unrolling correctly.
> 
> Should we need to add anything related to Unrolling to the target. I
> did not find the right document about this.
> 
>  Can any one please point me to the right direction...

There are several options that control loop unrolling in GCC, you could try tweaking them.  See GCC manual at http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Optimize-Options.html .  Now, given that this is a well-known benchmark you are looking at, there is a real possibility that GCC port for your target accidentally prevents loop-unrolling optimization.  You need to investigate why the instruction sequence your port is producing does not allow loop-unroller to do its job.

-funroll-loops
Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies -frerun-cse-after-loop. This option makes code larger, and may or may not make it run faster. 
-funroll-all-loops
Unroll all loops, even if their number of iterations is uncertain when the loop is entered. This usually makes programs run more slowly. -funroll-all-loops implies the same options as -funroll-loops, 

And --param options:

max-unrolled-insns
The maximum number of instructions that a loop should have if that loop is unrolled, and if the loop is unrolled, it determines how many times the loop code is unrolled. 
max-average-unrolled-insns
The maximum number of instructions biased by probabilities of their execution that a loop should have if that loop is unrolled, and if the loop is unrolled, it determines how many times the loop code is unrolled. 
max-unroll-times
The maximum number of unrollings of a single loop. 

--
Maxim Kuvyrkov
CodeSourcery/Mentor Graphics

  reply	other threads:[~2012-11-26  6:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23 15:02 naga raj
2012-11-26  6:43 ` Maxim Kuvyrkov [this message]
2012-11-26  8:31   ` naga raj
2012-11-30  2:13     ` Maxim Kuvyrkov
2012-11-30  4:02       ` naga raj

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=06230AFE-EC8F-4F19-BFCF-E7D1D6DF6CBE@codesourcery.com \
    --to=maxim@codesourcery.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gnuuser.raj@gmail.com \
    /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).