[Mono-dev] JIT and Inlining - why doesn't it happen?

Alan McGovern alan.mcgovern at gmail.com
Thu May 1 08:19:45 EDT 2008


Hi,

The method ch does get inlined alright:

INLINE START 00B23210
System.Security.Cryptography.SHA256Managed:ProcessBlock (byte[],int) ->
System.Security.Cryptography.SHA256Managed:Ch (uint,uint,uint)
created temp 24 of type System.UInt32
method to IR System.Security.Cryptography.SHA256Managed:Ch (uint,uint,uint)
created temp 25 of type System.Security.Cryptography.SHA256Managed
created temp 26 of type System.UInt32
created temp 27 of type System.UInt32
created temp 28 of type System.UInt32
INLINE END System.Security.Cryptography.SHA256Managed:ProcessBlock
(byte[],int) -> System.Security.Cryptography.SHA256Managed:Ch
(uint,uint,uint)

However, if i manually replace:
Ch(e, f, g);
with
((e&f) ^ (~e&g))

I get an 10% performance boost (give or take). Surely if the method was
getting inlined, that wouldn't be the case. Could it be that the temp
variables (25->28) aren't being dropped and there is excess variable copying
going on?

Alan.

On Thu, May 1, 2008 at 12:47 PM, Zoltan Varga <vargaz at gmail.com> wrote:

> Hi,
>
>  On my amd64 machine, that method does get inlined. You can check the
> output of mono -v -v -v -v for INLINE lines to see what gets inlined.
>
>                        Zoltan
>
> 2008/4/30 Alan McGovern <alan.mcgovern at gmail.com>:
> > This method does not get inlined:
> >
> > private uint Ch (uint u, uint v, uint w)
> > {
> >     return (u&v) ^ (~u&w);
> > }
> >
> > If that isn't inlined then don't ask me what kind of method *could* be
> > inlined by the JIT.
> >
> > Alan.
> >
> >
> >
> > On Wed, Apr 30, 2008 at 11:32 PM, Rodrigo Kumpera <kumpera at gmail.com>
> wrote:
> > > Mono only inline very short methods. Right now methods must have a
> body at
> > most 20 bytes long.
> > >
> > >
> > >
> > >
> > > 2008/4/30 Alan McGovern <alan.mcgovern at gmail.com>:
> > >
> > > >
> > > >
> > > >
> > > > I recently started doing a bit of optimisation work on the
> > hashing/cryptography classes in mono. When working on the managed SHA256
> > class[1], i noticed that mono isn't inlining what i'd consider some
> *very*
> > simple methods.
> > > >
> > > > The helper methods which do the bitshifting (Ro0, Ro1, Ch, Maj etc)
> > aren't inlined! Each of these methods is only called once in the code.
> By
> > manually inlining those method calls, performance increased
> significantly -
> > about 70%. Why isn't mono inlining these methods? Can mono be made
> inline
> > these?
> > > >
> > > > Alan.
> > > >
> > > >
> > [1]
> http://anonsvn.mono-project.com/viewcvs/trunk/mcs/class/corlib/System.Security.Cryptography/SHA256Managed.cs?rev=46462&view=markup
> > > >
> > > > _______________________________________________
> > > > Mono-devel-list mailing list
> > > > Mono-devel-list at lists.ximian.com
> > > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > > >
> > > >
> > >
> > >
> >
> >
> > _______________________________________________
> >  Mono-devel-list mailing list
> >  Mono-devel-list at lists.ximian.com
> >  http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080501/912ebd91/attachment.html 


More information about the Mono-devel-list mailing list