<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
diff attached<BR><BR> <BR>> Date: Mon, 8 Mar 2010 17:03:48 +0000<BR>> To: m3commit@elegosoft.com<BR>> From: jkrell@elego.de<BR>> Subject: [M3commit] CVS Update: cm3<BR>> <BR>> CVSROOT: /usr/cvs<BR>> Changes by: jkrell@birch. 10/03/08 17:03:48<BR>> <BR>> Modified files:<BR>> cm3/m3-sys/m3back/src/: M3x86.m3 Stackx86.i3 Stackx86.m3 <BR>> <BR>> Log message:<BR>> "rewrite" insert to not use tables and to inline 64bit operations<BR>> <BR>> It is modeled after:<BR>> <BR>> T insert(T to, T from, uint32 offset, uint32 count)<BR>> {<BR>> T mask = ((~((~(T)0) << count)) << offset);<BR>> return (to & ~mask) | ((from << offset) & mask);<BR>> }<BR>> <BR>> I spent some time trying to remove the unnecessary instructions.<BR>> No luck yet. The problem is the codegen wants to preserve offset/count<BR>> after we are done with them.<BR>> <BR>> The usage of the constant "-1" will be optimized later.<BR>> <BR>> Constant offset and count should generate much better code.<BR>> Just constant offset or count, not much different (shift immediate instead of shift by ecx).<BR>> er, actually the shifts might be significantly optimized.<BR>> Calculation of the mask ought to be better just for constant count, to be looked at later.<BR>> <BR>> It may be profitable to come up with other formulas.<BR>> These at least are "branch free" (except for the branches within the shifts).<BR>> <BR>> The basic general patterns are, which you can see follow the C code closely:<BR>> <BR>> insert Word.32<BR>> 00000226: 8B4DD0 MOV ECX tv.103[_n]<BR>> 00000229: BEFFFFFFFF MOV ESI $4294967295<BR>> 0000022E: D3E6 SHL ESI<BR>> 00000230: F7D6 NOT ESI<BR>> 00000232: 8BF9 MOV EDI ECX This isn't needed!<BR>> 00000234: 8B4DD8 MOV ECX tv.101[_m]<BR>> 00000237: D3E6 SHL ESI<BR>> 00000239: D3E2 SHL EDX<BR>> 0000023B: 23D6 AND EDX ESI<BR>> 0000023D: F7D6 NOT ESI<BR>> 0000023F: 23DE AND EBX ESI<BR>> 00000241: 0BDA OR EBX EDX<BR>> <BR>> insert Word.64<BR>> 000004EB: 8B4DB0 MOV ECX tv.117[_n]<BR>> 000004EE: BBFFFFFFFF MOV EBX $4294967295<BR>> 000004F3: BEFFFFFFFF MOV ESI $4294967295<BR>> 000004F8: 0FA5DE SHLD ESI EBX ECX<BR>> 000004FB: D3E3 SHL EBX<BR>> 000004FD: F6C120 TEST ECX $32<BR>> 00000500: 7400 JE rel8 L.75<BR>> 00000502: 8BF3 MOV ESI EBX<BR>> 00000504: 33DB XOR EBX EBX<BR>> set_label L.75<BR>> 00000506: F7D3 NOT EBX<BR>> 00000508: F7D6 NOT ESI<BR>> 0000050A: 8BF9 MOV EDI ECX<BR>> 0000050C: 8B4DB8 MOV ECX tv.115[_m]<BR>> 0000050F: 0FA5DE SHLD ESI EBX ECX<BR>> 00000512: D3E3 SHL EBX<BR>> 00000514: F6C120 TEST ECX $32<BR>> 00000517: 7400 JE rel8 L.76<BR>> 00000519: 8BF3 MOV ESI EBX<BR>> 0000051B: 33DB XOR EBX EBX<BR>> set_label L.76<BR>> 0000051D: 0FA5C2 SHLD EDX EAX ECX<BR>> 00000520: D3E0 SHL EAX<BR>> 00000522: F6C120 TEST ECX $32<BR>> 00000525: 7400 JE rel8 L.77<BR>> 00000527: 8BD0 MOV EDX EAX<BR>> 00000529: 33C0 XOR EAX EAX<BR>> set_label L.77<BR>> 0000052B: 23C3 AND EAX EBX<BR>> 0000052D: 23D6 AND EDX ESI<BR>> 0000052F: F7D3 NOT EBX<BR>> 00000531: F7D6 NOT ESI<BR>> declare_temp 4 4 Int.32 F tv.119[T$119] -88<BR>> 00000533: 897DA8 MOV tv.119[T$119] EDI This isn't needed!<BR>> 00000536: 8B7DE8 MOV EDI tv.108[_a64]<BR>> declare_temp 4 4 Int.32 F tv.120[T$120] -92<BR>> 00000539: 894DA4 MOV tv.120[T$120] ECX This isn't needed!<BR>> 0000053C: 8B4DEC MOV ECX tv.108[_a64]+4<BR>> 0000053F: 23FB AND EDI EBX<BR>> 00000541: 23CE AND ECX ESI<BR>> 00000543: 0BF8 OR EDI EAX<BR>> 00000545: 0BCA OR ECX EDX<BR>> free_temp tv.120[T$120]<BR>> free_temp tv.119[T$119]<BR>> <BR> </body>
</html>