[Mono-devel-list] [PATCH] ABCREM improvements

Massimiliano Mantione massi at ximian.com
Tue Jan 18 06:19:32 EST 2005

This is the result of working on bug 71062.

Before, abcrem performed a symbolic computation of simple
algebraic expressions, and only on local variables or
arguments. Now also variable types are taken into account
(they obviously affect value ranges), as well as conversion
operations and the '&' operator (when it is obviously used
to "clamp" values).
Moreover, the length of arrays stored in static readonly
fields is detected (if the field has been initialized when
the method is compiled, so not with AOT and in cases where
the initialization is postponed, sorry).

Basically, all the issues described in the bug report have
been addressed, including some other scenario (like loading
integer values from array elements or object fields, also
here the type is considered).

The attached program (sbox.cs) is a variation of the example
that Sebastien attached to the bug report, and it is a sort
of microbenchmark for some cryptographic functions.
The same function is implemented in four different ways.

This table shows the result (in seconds) of running it with a
fixed number of iterations for each of the implementations,
with and without abcrem.
(the commans is "mono -O={...} sbox.exe 200000000")

          -O=all,-abcrem   -O=all     abc overhead
Int32     3.23             3.02       6.87%
Byte      3.51             3.44       2.21%
VarCast   3.23             3.02       7.12%
IndexCast 2.97             2.91       2.04%

The function that Sebastien was originally testing was "Int32",
and we already have a nice gain there (almost 7%).
Byte was a variation he did hoping that abcrem would work, but
it is suboptimal in itself...
The other two are variations I introduced to test if abcrem was
working in all cases, and it does :-)
The total gain from "Int32" without abcrem to "IndexCast" with
abcrem is about 10%.

Actually, the gain from "Int32" to "VarCast" is caused by the
fact that casting to byte is better than using '& 0xff'.
Moreover, the gain from "VarCast" to "IndexCast" are probably
caused by the fact that copyprop does not work well with SSA
(in fact "IndexCast" is just "VarCast" with less variables in
the middle).
I think that as soon as I'll add GVN to SSAPRE (so that SSAPRE
will do copyprop as well) "VarCast" will be like "IndexCast".
Nevertheless, as I said, abcrem works in all cases...

If nobody objects I'll commit by the end of the week, and
close the bug.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: abcrem.patch
Type: text/x-patch
Size: 25708 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050118/34372801/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sbox.cs
Type: text/x-csharp
Size: 3608 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050118/34372801/attachment-0001.bin 

More information about the Mono-devel-list mailing list