Using the GCC Compiler for ARM (windows):
arm-none-eabi-gcc.exe (Sourcery CodeBench Lite 2012.09-63) 4.7.2 version
I have another object file created every ~ 5 times, I compiled the same source file.
Optimization level 3 (aggressive) is used, compiler parameters used:
-O3 -mcpu = cortex-a8 -mfpu = neon -mfloat-abi = softfp -fshort-wchar -fshort-enums -funsafe-math-optimizations -mvectorize-with-neon-quad
A dump of different object files (using objdump) shows too many differences in the assembly instructions, the registers and addresses used.
Is it normal that the compiler optimizes / compiles the exact same source file in different ways and creates different object files ?! Is this a compiler error?
How to avoid this behavior without disabling aggressive optimization?
EDIT: fragment of object fragments:
object_file_dump_A:
0000350 <PreInit>: 350: e3003000 movw r3,
object_file_dump_B:
00000350 <PreInit>: 350: e3003000 movw r3,
EDIT:
source:
void PreInit(init_T *f_params, results_T *results) { u8 i, j, k, idx; const u8 cr_index[4] = {0, 1, 2, 7}; const u8 minVal[] = {2, 4, 6, 0, 0, 0, 0, 19}; const u8 maxVal[] = {0, 3, 5, 0, 0, 0, 0, 18}; memset(f_params, 0, sizeof(init_T)); _ASSERT(CONF_NUM_X_LIMITS == CST_NbSLi); _ASSERT(CONF_NUM_CRITERIA == CST_NbIdxCriteria); for (i = 0; i < CST_NbSLi; ++i) { f_params->_sli[i].x = s_limits[i]; for (j = 0; j < CST_NbIdxCriteria; ++j) { f_params->_sli[i].criteria[j] = conf_criterias[i][j]; } } /*some code*/ }