Sorry if this is the wrong forum for this question. It regards a version of GCC supplied with Eclipse by Freescale. I am using e6500 64 bit mode. (I'm not exactly clear on the role of Freescale versus NXP, the datasheets are all from the latter while the compiler appears to be the former.)
Compiler: powerpc-aeabi-gcc-4.9.2.exe
Version: powerpc-aeabi-gcc-4.9.2.exe (GCC) 4.9.2 20141030 (Mon Nov 16 18:12:40 CST 2015 build.sh rev=1267 s=F492 ELe6500 -V release_r1267_build_Fed_ELe6500)
Copyright (C) 2014 Free Software Foundation, Inc.
I know claims of compiler bug are almost always wrong, the following small snippet looks like there's a off-by-one problem. I'm searching a string for a letter, in this case 'e'. It loads string address into R10 and grabs a character from that address +1 into R9 for comparison. Depending on optimization level I've seen a preceding decrement on the address pointer but not always. The following code was compiled with -O2.
C: (This is part of my XXXprintf implementation.)
const int nfmtstr = 19;
const char *fmtstr = "diouxXfFeEgGaAcspPn";
int j;
for(j=0;j<nfmtstr;j++)
if (fmtstr[j]=='e')
break;
Emitted:
mflr r0
ld r10,0(r2) # Address updated during load via relocation record, points to 19 char string.
std r0,16(r1)
li r9,19
stdu r1,-112(r1)
li r3,0
mtctr r9
nop
lbzu r9,1(r10) # Skips first char.
addi r8,r3,1
cmpwi cr7,r9,101
Any direction would be greatly appreciated.