# Avoid Unnecessary 16-Byte Alignment

This method should only be used in certain situations that are well understood. It can potentially cause correctness issues when linking with other objects or libraries that aren't built with this option. This topic only applies to Linux systems on IA-32 architecture.

The 32-bit Linux ABI states that stacks need only maintain 4-byte alignment. However, for performance reasons in modern architectures, GCC and ICC maintain an alignment of 16-bytes on the stack. Maintaining 16-byte alignment may require additional instructions to adjust the stack on function entries where no stack adjustment would otherwise be needed. This can impact code size, especially in code that consists of many small routines.

You can specify a compiler option that will revert ICC back to maintaining 4-byte alignment, which can eliminate the need for extra stack adjust instructions in some cases.

Use this option only if one of the following is true:

- Your code does not call any other object or library that can be built without this option and, therefore, may rely on the stack being aligned to 16-bytes when called.

- Your code is targeted for architectures that do not have or support SSE instructions; therefore, it would never need 16-byte alignment for correctness reasons.

Options to specify:

Linux*: | -falign-stack=assume-4-byte
macOS*: | None
Windows*: | None

Advantages of this method: | Code size can be smaller because you do not need extra instructions to maintain 16-byte alignment when not needed. This method can improve performance in some cases because of this reduction of instructions.
Disadvantages of this method: | This method can cause incompatibility when linked with other objects or libraries that rely on the stack being 16-byte aligned across the calls.

Notes:

Depending on code characteristics, this option can sometimes increase binary size.

Parent topic: Methods to Optimize Code Size