Porting 32 bit C++ code to 64 bit - is it worth it? Why?

前端 未结 19 2844
攒了一身酷
攒了一身酷 2020-12-24 00:58

I am aware of some the obvious gains of the x64 architecture (higher addressable RAM addresses, etc)... but:

  • What if my program has no real need to run in nati
19条回答
  •  天命终不由人
    2020-12-24 01:37

    Here's what 64-bit does for you:

    • 64-bit allows you to use more memory than a 32-bit app.
    • 64-bit makes all pointers 64-bits, which makes your code footprint larger.
    • 64-bit gives you more integer and floating point registers, which causes less spilling registers to memory, which should speed up your app somewhat.
    • 64-bit can make 64-bit ALU operations faster (only helpful if you're using 64-bit data types).
    • You DO NOT get any extra security (another answer mentioned security, I'm not aware of any benefits like that).
    • You're limited to only running on 64-bit operating systems.

    I've ported a number of C++ apps and seen about a 10% speedup with 64-bit code (same system, same compiler, the only change was a 32-bit vs 64-bit compiler mode), but most of those apps were doing a fair amount of 64-bit math. YMMV.

    I wouldn't worry about 32-bit support going away any time soon.

    (Edited to include notes from comments - thanks!)

提交回复
热议问题