Hmm. If you actually get the information C5912, than it sounds like a bug.
When I tried to reproduce it (see the code below) that message was not issued.
Note that the compiler is only emmiting the code for the second assingment to afAddrInfo.aClusterId[1] once as that is actually assigning the same value in both conditions.
So is the problem you observe that the second line gets merged, or is it that both conditions do get folded?
The condition folding would be a bug, please could you provide a complete compilable sample of the actual code, best with a listing file so we see the output.
If the problem is "just" the optimization of the merged second line, then use the options
"-onb=t -onbt -onf"
The first two are disabling two levels of branch tail merging, the third one (-onf, common code) is was also collecting the identical code once the branch tail merging was disabled.
Daniel
Here's the code I tried to reproduce the issue:
struct {
unsigned char aClusterId[2];
} afAddrInfo;
#define TRUE 1
int abc;
void test(void) {
/* put your own code here */
#define mDeviceJoinReqClusterID 0x1201
#define mDataClusterId_c 0x1200
if (abc == TRUE) {
afAddrInfo.aClusterId[0] = (mDeviceJoinReqClusterID & 0xFF);
afAddrInfo.aClusterId[1] = (mDeviceJoinReqClusterID>> 8);
} else {
afAddrInfo.aClusterId[0] = (mDataClusterId_c & 0xFF);
afAddrInfo.aClusterId[1] = (mDataClusterId_c >> 8);
}
}
This code did generate the following code which looks correct, as far as I see. (The code is optimized, without the options to disable the branch tail merging).
13: if (abc == TRUE) {
0000 c60001 [4] LDA abc:1
0003 4b08 [3] DBNZA LD ;abs = 000d
0005 c60000 [4] LDA abc
0008 2603 [3] BNE LD ;abs = 000d
14: afAddrInfo.aClusterId[0] = (mDeviceJoinReqClusterID & 0xFF);
000a a601 [2] LDA #1
15: afAddrInfo.aClusterId[1] = (mDeviceJoinReqClusterID>> 8);
16: } else {
000c 21 [3] SKIP1 LE ;abs = 000e
000d LD:
17: afAddrInfo.aClusterId[0] = (mDataClusterId_c & 0xFF);
000d 4f [1] CLRA
000e LE:
000e c70000 [4] STA afAddrInfo
18: afAddrInfo.aClusterId[1] = (mDataClusterId_c >> 8);
0011 a612 [2] LDA #18
0013 c70001 [4] STA afAddrInfo:1
19: }
20: }
0016 81 [4] RTS
21: