Average number of instructions per line of kernel code

NightStrike nightstrike@gmail.com
Thu Aug 30 14:25:00 GMT 2007


On 8/30/07, Mohamed Bamakhrama <bamakhrama@gmail.com> wrote:
> On 8/30/07, Tom St Denis <tstdenis@ellipticsemi.com> wrote:
> > Mohamed Bamakhrama wrote:
> > > Hi all,
> > > I have a question regarding the average number of assembly
> > > instructions per line of kernel code. I know that this is a difficult
> > > question since it depends on many factors such as the instruction set
> > > architecture, compiler used, optimizations used, type of code, coding
> > > style, etc...
> > > I would like to know a rough estimate for such a quantity for the
> > > kernel 2.4/2.6 code running on MIPS32 architecture compiled using GCC.
> > > My estimate is between 5-10 instructions. I googled for such a thing
> > > but couldn't find any useful papers/resources.
> > >
> >
> > I don't understand what use this metric is.
> >
> > For starters, not all lines are created equal.  Not all lines contain
> > code, not all lines with code produce output (hint: dead code).  Not all
> > lines contain a single statement, etc....
> >
>
> Hi,
> I understand that it doesn't sound interesting at all for programmers.
> Nevertheless, this metric is interesting for hardware architects since
> it gives you a hint about the instruction cache behavior of your code.
> If somehow you know how many instructions can result from one
> statement *on average*, then it can help you somehow in calculating
> optimal parameters for the cache (assuming that you can find the
> length of the basic blocks within your C code).

Then what you need is to count the actual number of statements in the
code and not just lines of text.  There's a very big difference there.



More information about the Gcc-help mailing list