On Mon, Nov 25, 2002 at 05:40:36PM +0100, Leopold Toetsch wrote:
> Nicholas Clark wrote:
> >Is there any speed advantage in truncating by casting via a C type
> >[eg a = (int)(short) b]
> >rather than and on a bitmask
> >[eg a = b & 0xFFFF]
> >?
>
>
> gcc uses MOVSX (movs{b,w}l), move byte/word with sign extend to 32 bit.
> This is listed to take 3 cycles which "and mem" needs too. Inkluding
> sign extension would be slower then.
What I didn't notice was that the 8 bit signed ops cast via char.
This isn't portable, as char is unsigned on PPC and ARM (and possibly other
platforms.) I've committed this:
--- dotgnu.ops~ Tue Nov 26 18:56:43 2002
+++ dotgnu.ops Sat Nov 30 16:09:08 2002
@@ -18,13 +18,13 @@ Additional opcodes for C# compilation ne
=cut
inline op conv_i1(inout INT) {
- $1 = (INTVAL)((char)($1));
+ $1 = (INTVAL)((signed char)($1));
goto NEXT();
}
inline op conv_i1_ovf(inout INT) {
if($1 >= -128 && $1 <= 127) {
- $1 = (INTVAL)((char)($1));
+ $1 = (INTVAL)((signed char)($1));
}
else {
internal_exception(1, "Overflow exception for conv_i1_ovf\n");
Nicholas Clark
--
Brainfuck better than perl? http://www.perl.org/advocacy/spoofathon/