Tool/software: TI C/C++ Compiler
TI v6.4.2 compiler, when the [3 interprocedure optimization] is selected, the first type OR operation of the test code will be optimized as follows,
The high eight bits of the variable tmp_1st are not assigned, which results in an error in the result of the operation. The second type OR operation has no problem.
I tried to use a higher version of the compiler (TI v18.1.4.LTS) and confirmed the phenomenon.
The above problems will not occur when the same code is executed and the [3 interprocedure optimization] are executed.
Is it a problem with the compiler TI v6.4.2?
#include <stdio.h>
unsigned pData[2] = {1,2};
typedef union{
unsigned Word[2];
unsigned long Dword;
}wordDWord;
long value_1st,value_2nd = 0;
int main(void) {
long tmp_1st,tmp_2nd;
if(0x0080 & tmp_1st){
tmp_1st |= 0xFFFFFF00;
}
if(0x0080 & tmp_2nd){
tmp_2nd = tmp_2nd | 0xFFFFFF00;
}
value_1st = tmp_1st;
value_2nd = tmp_2nd;
return 0;
}