I'm using unaligned and aligned load intrinsics in my code and ICC does not behave as I expect it to. If this is expected behavior, can somebody educate me on why?
The fundamental problem is I expect aligned load intrinsics to generate aligned instructions while unaligned intrinsics generate unaligned instructions However, what I see is that depending on compiler flags sometimes aligned load intrinsics generate unaligned instructions.
I've attached a snippet of code to demonstrate. I realize this code will segfault when run. The point is just to compile and and look at the generated assembly code.
There are 3 cases I experimented with (comments in the code give compiler version and detailed compile arguments)
- gcc - GNU compiler behaves as expected meaning that aligned load intrinsics map to aligned load instructions.
- icc with no "-m" argument. This works exactly like gcc. Aligned loads map to aligned intrinsics.
- icc with '-mavx' argument. (Note gcc requires this argument to even compile the example). With this argument aligned load intrinsics use unaligned load instructions. The same also happens with '-msse4.2'