public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/63742] New: arm *movhi_insn_arch4 pattern may emit ldrh which is wrong for big-endian
@ 2014-11-05 6:49 fei.yang0953 at gmail dot com
2014-11-05 7:14 ` [Bug target/63742] " fei.yang0953 at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: fei.yang0953 at gmail dot com @ 2014-11-05 6:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63742
Bug ID: 63742
Summary: arm *movhi_insn_arch4 pattern may emit ldrh which is
wrong for big-endian
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: fei.yang0953 at gmail dot com
CC: ramana.radhakrishnan at arm dot com
Host: x86_64-suse-linux
Target: armeb-linux-gnueabi-gcc
Build: x86_64-suse-linux
Simple testcase (test.c):
unsigned short v;
int i;
int j = 0;
int *ptr = &j;
unsigned short func()
{
for (i = 0; i < 1; ++i)
{
*ptr = -1;
v = 0x1234;
}
return v;
}
Compile option: armeb-linux-gnueabi-gcc -S -O1 test.c
Assembly code snippet:
func:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
str lr, [sp, #-4]!
movw r3, #:lower16:i
movt r3, #:upper16:i
mov r2, #0
str r2, [r3]
movw r0, #:lower16:.LANCHOR0
movt r0, #:upper16:.LANCHOR0
mvn lr, #0
movw r1, #:lower16:v
movt r1, #:upper16:v
ldrh ip, .L5 @ movhi
mov r2, r3
.L2:
ldr r3, [r0]
str lr, [r3]
strh ip, [r1] @ movhi
ldr r3, [r2]
add r3, r3, #1
str r3, [r2]
cmp r3, #0
ble .L2
movw r3, #:lower16:v
movt r3, #:upper16:v
ldrh r0, [r3]
ldr pc, [sp], #4
.L6:
.align 2
.L5:
.word 4660
Issue under big-endian:
The ldrh loads the wrong value as immediate 4660 is in big-endian form.
GCC version: gcc version 5.0.0 20141026 (experimental)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-05 7:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-05 6:49 [Bug target/63742] New: arm *movhi_insn_arch4 pattern may emit ldrh which is wrong for big-endian fei.yang0953 at gmail dot com
2014-11-05 7:14 ` [Bug target/63742] " fei.yang0953 at gmail dot com
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).