|
32 | 32 | this to be the same as unaligned access. On x86/64 we can be more relaxed both |
33 | 33 | with aliasing and alignment, but if at some point a compiler starts to |
34 | 34 | modify this behaviour, the header can be updated or PORTABLE_MEM_PTR_ACCESS |
35 | | - can be defined to 0 in the build configuration, or this file can be updated. */ |
| 35 | + can be defined to 0 in the build configuration, or this file can be updated. |
| 36 | +
|
| 37 | + The balance is betweem knowing memcpy or __builtin_memcpy is fast, |
| 38 | + and knowing that pointer casts do not break. |
| 39 | +
|
| 40 | + Known targets that require PORTABLE_MEM_PTR_ACCESS=0 for at least some version: |
| 41 | +
|
| 42 | + - ARM cross compiler: arm-none-eabi, -O2, -mcpu=cortext-m7, |
| 43 | + breaks on PORTABLE_MEM_PTR_ACCESS=0 |
| 44 | + slow memcpy, has fast __builtin_memcpy |
| 45 | +
|
| 46 | + - Intel ICC -O3 on x86/64 (that compiler is deprecated by Intel). |
| 47 | + breaks on PORTABLE_MEM_PTR_ACCESS=0 |
| 48 | + has __builtin_memcpy, performance unknown, memcpy perforamnce unknown. |
| 49 | +
|
| 50 | + */ |
36 | 51 |
|
37 | 52 |
|
38 | 53 | /* NOTE: for best performance, `__builtin_memcpy` should be detectable, but |
@@ -63,7 +78,11 @@ extern "C" { |
63 | 78 |
|
64 | 79 | #ifndef PORTABLE_MEM_PTR_ACCESS |
65 | 80 |
|
66 | | -#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) |
| 81 | +#if defined(__INTEL_COMPILER) |
| 82 | +# /* Prevents Intel ICC compiler from breaking on -O3 on x86/64 target, |
| 83 | + likely due to strict aliasing rules. */ |
| 84 | +# define PORTABLE_MEM_PTR_ACCESS 0 |
| 85 | +#elif (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) |
67 | 86 | # define PORTABLE_MEM_PTR_ACCESS 1 |
68 | 87 | #else |
69 | 88 | # define PORTABLE_MEM_PTR_ACCESS 0 |
|
0 commit comments