public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59593] New: [arm big-endian] using "ldrh" access a  immediate  which stored in a memory by word
@ 2013-12-24 14:25 spf_zju at 126 dot com
  2013-12-24 14:46 ` [Bug target/59593] " mpolacek at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: spf_zju at 126 dot com @ 2013-12-24 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59593
           Summary: [arm big-endian] using "ldrh" access a  immediate
                    which stored in a memory by word
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: spf_zju at 126 dot com

the C code like this:

short int a = 1;
int test()
{
  return 922 * a;
}

compile the C code : arm-eabi-gcc -mbig-endian -O2 -S bar.c -o bar.s 

the bar.s like this :

movw r3, #:lower16:.LANCHOR0
movt r3, #:upper16:.LANCHOR0
ldrh r0, [r3,#0]
ldrh r3, .L2
smulbb r0, r0, r3
bx lr

.L3:
   .align 2
.L2:
   .word 922 

The immediate 922 is stored in .L2, in arm big-endian mode  ,the memory of .L2
is like this 0x0000039a, so when executing this "ldrh r0, [r3,#0]", the r0 is
zero,so the result is wrong .

also see the disassembly of bar.o :

   <test>:
0: e3003000  movw r3, #0
4: e3403000  movt r3, #0
8: e1d300b0  ldrh r0,[r3]
c: e1df30b4  ldrh r3,[pc,#4]   ;18
10:e1b00380  smulbb r0,r0,r3
14:e12fff1e  bx lr 
18:0000039a  muleq r0,sl,r3

So the return value of the function test is zero. it is wrong .


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-10-30  1:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-24 14:25 [Bug c/59593] New: [arm big-endian] using "ldrh" access a immediate which stored in a memory by word spf_zju at 126 dot com
2013-12-24 14:46 ` [Bug target/59593] " mpolacek at gcc dot gnu.org
2014-01-02 15:18 ` rearnsha at gcc dot gnu.org
2014-11-05 17:24 ` rearnsha at gcc dot gnu.org
2014-11-19 13:46 ` fyang at gcc dot gnu.org
2014-11-20  8:39 ` ramana at gcc dot gnu.org
2014-11-27 11:00 ` thopre01 at gcc dot gnu.org
2014-12-03 13:40 ` fyang at gcc dot gnu.org
2014-12-04 15:16 ` fyang at gcc dot gnu.org
2015-03-04  5:51 ` thopre01 at gcc dot gnu.org
2015-03-04  5:57 ` thopre01 at gcc dot gnu.org
2015-06-02  6:28 ` wad at infinet dot ru
2015-10-30  1:46 ` thopre01 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).