Disassembly view of C# 64-bit Release code is 75% longer than 32-bit Debug code?

前端 未结 3 1651
面向向阳花
面向向阳花 2020-12-21 00:27

EDIT

I tested release in 32 bit, and the code was compact. Therefore the below is a 64 bit issue.


I\'m using VS 2012 RC. Debug is 32 b

3条回答
  •  無奈伤痛
    2020-12-21 01:11

    I suspect you are using "Go to disassembly" while debugging the release build to get the assembly code.

    After going to Tools -> Options, Debugging, General, and disabling "Suppress JIT optimization on module load" I got an x64 assembly listing without error checking.

    It seems like by default even in release mode the code is not optimized if the debugger attached. Keep that in mind when trying to benchmark your code.

    PS: Benchmarking shows x64 slightly faster than x86, 4.3 vs 4.8 seconds for 1 billion function calls.

    Edit: Break points still worked for me, otherwise I wouldn't have been able to see the disassembly after unchecking. Your example line from above looks like this (VS 2012 RC):

    crc = (crc >> 8) ^ crcTable[((val & 0x0000ff00) >> 8) ^ crc & 0xff];
    00000030  mov         r11d,eax 
    00000033  shr         r11d,8 
    00000037  mov         ecx,edx 
    00000039  and         ecx,0FF00h 
    0000003f  shr         ecx,8 
    00000042  movzx       eax,al 
    00000045  xor         ecx,eax 
    00000047  mov         eax,ecx 
    00000049  cmp         rax,r9 
    0000004c  jae         00000000000000A4 
    0000004e  mov         eax,dword ptr [r8+rax*4+10h] 
    00000053  xor         r11d,eax 
    

提交回复
热议问题