This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/11916] New: Arm optimizer, Missing increment of char pointer


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11916

           Summary: Arm optimizer, Missing increment of char pointer
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: matrix at o3games dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: ppc-darwin
GCC target triplet: arm-elf

------- BEGIN arm_error.c -------
/*
  compiler info:
  Reading specs from /Users/kma/Desktop/gnude/bin/../lib/gcc-lib/arm-elf/3.3/specs
  Configured with: ../gcc-3.3/configure --prefix=/gnude --target=arm-elf
--enable-multilib --enable-interwork --disable-shared --with-newlib
  Thread model: single
  gcc version 3.3


  compile with:
  arm-elf-gcc -c -O1 -mbig-endian -mhard-float -o main.o main.c
*/

static char aHex[16] =
{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static char aNumBuf[3] = {'0','0',0};

int main()
{
	char *pMem = 0x1000;
	int y, x;
	for(y = 0; y < 4; y++)
		for(x = 0; x < 4; x++)
		{
			aNumBuf[0] = aHex[(*pMem)>>4];
			aNumBuf[1] = aHex[(*pMem)&0xf];
			
			pMem++; // problem statement
		}
	return pMem;
}
----- END arm_error.c ------

When this code is compiled without the -O1 flag it works fine and returns the
correct value. With -O1 turned on, it returns 0x1000, the value of pMem doesn't
change. If you look at the assembler code that it produces, you will se that it
loads 0x1000 into r0 and never changes that value. A 'add r0,r0,1' instruction
has gone is missing or a write-back bit on a ldr/str instruction.

I tried this on both 3.3 and 3.0.4

Temporary solutions: Don't use the optimizations


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]