Depending on the architecture, the code may also grow. Global variables and constant are often referenced via absolute addresses (which are moved by the program loader), these links are 64-bit in 64-bit mode. On x64 there is an explicit mov command for 64-bit constants, so the program will only increase in size of the constant. Jump and call commands may also increase, but this depends on many parameters of the compiler and linker. On other architectures, this can be even worse. For example, in SPARC, when switching from 32 to 64 bits, the code can increase significantly. Since sparc does not have an instruction that can load more than 22 bits, when loading a 32-bit address of a global variable or constant, it needs 2 instructions, to load a 64-bit constant it even needs 5 instructions with 3 registers. By increasing the pressure in the register, the compiler often skips optimization opportunities, making the code much larger than necessary.
Patrick schlüter
source share