<div>Hi,</div>
<div> </div>
<div>Currently I develop own compiler using LLVM ( and MS Phoenix framework =) )  and found that 'fptoui' instruction usage in following situation crashes JIT:</div>
<div>;===========================================<br clear="all">@System.Test.ByteOrderTests.big2 = internal global i32 60994<br>@str = internal constant [18 x i8] c"Big endian: %lld\0A\00"<br></div>
<div>declare i32 @printf(i8* nocapture, ...) nounwind<br>declare i32 @llvm.bswap.i32(i32) nounwind readnone</div>
<div>define void @main() {<br>  %1 = load i32* @System.Test.ByteOrderTests.big2 ; <i32> [#uses=1]<br>  %2 = call i32 @llvm.bswap.i32(i32 %1)<br>  %3 = bitcast i32 %2 to float<br>  %4 = fptoui float %3 to i64<br>  %yo = call i32(i8* nocapture, ...)* @printf( i8* getelementptr ([18 x i8]* @str, i32 0, i64 0), i64 %4 )</div>

<div>  ret void<br>}<br>;Writes:</div>
<div>;0.      Program arguments: lli test.bc<br>;00000000 (0x42EE0000 0x00000000 0x00D6FA60 0x01280E01) <unknown module><br>;001D0023 (0x00C1F664 0x00C48F50 0x00C1F734 0x54AD8E88) <unknown module><br>;0153245C (0x00C48F50 0x022941BC 0x00D61D18 0x54AD80F4), llvm::ExecutionEngine::runFunctionAsMain()+0940 bytes(s), e:\external\llvm\lib\executionengine\executionengine.cpp, line 387+0030 byte(s)<br>
;01272C44 (0x00000002 0x00D680F8 0x00D61D18 0x54AD80A4), main()+2196 bytes(s), e:\external\llvm\tools\lli\lli.cpp, line 218+0064 byte(s)<br>;01C5FF78 (0x00C1F984 0x74DB3677 0x7EFDE000 0x00C1F9C4), __tmainCRTStartup()+0424 bytes(s), f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, line 586+0025 byte(s)<br>
;01C5FDBF (0x7EFDE000 0x00C1F9C4 0x77159D72 0x7EFDE000), mainCRTStartup()+0015 bytes(s), f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, line 403<br>;74DB3677 (0x7EFDE000 0x778EDA85 0x00000000 0x00000000), BaseThreadInitThunk()+0018 bytes(s)<br>
;77159D72 (0x01C5FDB0 0x7EFDE000 0x00000000 0x00000000), RtlInitializeExceptionChain()+0099 bytes(s)<br>;77159D45 (0x01C5FDB0 0x7EFDE000 0x00000000 0x00000000), RtlInitializeExceptionChain()+0054 bytes(s)</div>
<div>;===========================================<br clear="all">But if I change 'fptoui' to 'fptosi' everything is OK:</div>
<div> </div>
<div></div>
<div>@System.Test.ByteOrderTests.big2 = internal global i32 60994<br>@str = internal constant [18 x i8] c"Big endian: %lld\0A\00"<br></div>
<div>declare i32 @printf(i8* nocapture, ...) nounwind<br>declare i32 @llvm.bswap.i32(i32) nounwind readnone</div>
<p>define void @main() {<br>  %1 = load i32* @System.Test.ByteOrderTests.big2 ; <i32> [#uses=1]<br>  %2 = call i32 @llvm.bswap.i32(i32 %1)<br>  %3 = bitcast i32 %2 to float<br>  %4 = fptosi float %3 to i64<br>  %yo = call i32(i8* nocapture, ...)* @printf( i8* getelementptr ([18 x i8]* @str, i32 0, i64 0), i64 %4 )</p>

<div>  ret void<br>}</div>
<div>;Writes: Big endian: 119<br>;===========================================<br clear="all"></div>
<div>I'm using llvm from trunk (23 sept 2009) on Windows 7 ( build 7600 )</div>
<div>To run test I used:</div>
<div>  llvm-as test.ll</div>
<div>  lli test.bc</div>
<div> </div>
<div>-- <br>WBR,<br>Eugeny Grishul<br></div>