Bug 22528 - Optimized ARM 'unsigned short's assignments are incorrect for big-endian ARMv3 targets
Summary: Optimized ARM 'unsigned short's assignments are incorrect for big-endian ARMv...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 24528 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-17 18:28 UTC by Gavin J Stark
Modified: 2005-10-26 12:33 UTC (History)
3 users (show)

See Also:
Host: i*86-*-linux
Target: arm-linux-elf
Build: arm-linux-gcc?
Known to work: 3.4.4
Known to fail: 3.3.6
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin J Stark 2005-07-17 18:28:22 UTC
//Reading specs from /usr/local/cross-arm/bin/../lib/gcc-lib/arm-linux/3.3.2/specs
//Configured with:
/home/localgjs/tnbt_cvstrees/software/tools/gcc/../../tools/gcc/configure
--target=arm-linux --disable-shared --disable-threads --with-gnu-as
--with-gnu-ld --enable-multilib --enable-languages=c
--prefix=/usr/local/cross_arm
--with-headers=/home/localgjs/tnbt_cvstrees/software/tools/gcc/../../os/linux/include/
//Thread model: single
//gcc version 3.3.2

// This fails if compiled with... /usr/local/cross-arm/bin/arm-linux-gcc -O1
-mbig-endian -march=armv3 -o test.o -c test.c
// It generates code which sets *us to be 0, not 0x800
// With not big-endian, or without optimization, or with a Thumb-capable arch,
it works
void test(unsigned short *us)
{
    *us = (unsigned short)0x800;
    return;
}

Output code from above:
Disassembly of section .text:

00000000 <test>:
   0:   e3a03000        mov     r3, #0  ; 0x0
   4:   e5c03000        strb    r3, [r0]
   8:   e5c03001        strb    r3, [r0, #1]
   c:   e1a0f00e        mov     pc, lr

If built without -big-endian the output is correct:
Disassembly of section .text:

00000000 <test>:
   0:   e3a03000        mov     r3, #0  ; 0x0
   4:   e5c03000        strb    r3, [r0]
   8:   e3a03008        mov     r3, #8  ; 0x8
   c:   e5c03001        strb    r3, [r0, #1]
  10:   e1a0f00e        mov     pc, lr
Comment 1 Pawel Sikora 2005-07-17 18:50:16 UTC
gcc-4.0.1 works fine. 
 
$ arm-linux-eabi-gcc gcc-pr22528.c -O2 -march=armv3 -S -mlittle-endian 
 
test: 
        mov     r3, #8 
        mov     r2, #0 
        strb    r3, [r0, #1] 
        strb    r2, [r0, #0] 
        mov     pc, lr 
 
$ arm-linux-eabi-gcc gcc-pr22528.c -O2 -march=armv3 -S -mbig-endian 
 
test: 
        mov     r3, #0 
        mov     r2, #8 
        strb    r3, [r0, #1] 
        strb    r2, [r0, #0] 
        mov     pc, lr 
 
Comment 2 Richard Earnshaw 2005-08-12 11:13:20 UTC
The 3.3 branch is no-longer being maintained, and this was fixed in gcc-3.4.

If you need to patch a 3.3 compiler you can apply the patch from here:

http://gcc.gnu.org/ml/gcc-patches/2003-11/msg00832.html
Comment 3 Richard Earnshaw 2005-10-26 12:33:46 UTC
*** Bug 24528 has been marked as a duplicate of this bug. ***