public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* target/1947: gcc for target xscale generates incorrect code when optimization is turned on
@ 2001-04-01 0:00 vmoorthy
0 siblings, 0 replies; 2+ messages in thread
From: vmoorthy @ 2001-04-01 0:00 UTC (permalink / raw)
To: gcc-gnats; +Cc: jimw
>Number: 1947
>Category: target
>Synopsis: gcc for target xscale generates incorrect code when optimization is turned on
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Feb 12 07:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Vijay Moorthy
>Release: 2.9-xscale-001130
>Organization:
>Environment:
gcc for target==xscale-elf build=sun-sparc-solaris2.8
>Description:
Here a test program. Note that testa and testb should behave differently.
In particular is x is big positive and y is big negative, the subtraction
will overflow resulting in a negative number, whereas the "<" should be
false. The compiler however generates the same code for each when optimizations
are turned on.
int testa(int x,int y) {
if ( x-y < 0 )
return 1;
else
return 0;
}
int testb(int x, int y) {
if ( x < y )
return 1;
else
return 2;
}
This problem seems to be specific to the xscale target, and
does not occur for the "strongarm" target.
>How-To-Repeat:
Here is complete C source :
-----------------------------
int testa(int x,int y) {
if ( x-y < 0 )
return 1;
else
return 0;
}
int testb(int x, int y) {
if ( x < y )
return 1;
else
return 2;
}
---------------------------------
Compile with the following command line:
xscale-elf-gcc -S -O2 test.c
The following is the (incorrect) assembly output:
-----------------------------------
@ Generated by gcc 2.9-xscale-001130 for ARM/elf
.file "test.c"
.gcc2_compiled.:
.text
.align 2
.global testa
.type testa,function
testa:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, current_function_anonymous_args = 0
cmp r0, r1
movge r0, #0
movlt r0, #1
mov pc, lr
.Lfe1:
.size testa,.Lfe1-testa
.align 2
.global testb
.type testb,function
testb:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, current_function_anonymous_args = 0
cmp r0, r1
movge r0, #2
movlt r0, #1
mov pc, lr
.Lfe2:
.size testb,.Lfe2-testb
--------------------------------------------
Without optimizations, the following (correct) code is genertated:
---------------------------------------------
@ Generated by gcc 2.9-xscale-001130 for ARM/elf
.file "test.c"
.gcc2_compiled.:
.text
.align 2
.global testa
.type testa,function
testa:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, current_function_anonymous_args = 0
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
sub sp, sp, #8
str r0, [fp, #-16]
str r1, [fp, #-20]
ldr r3, [fp, #-16]
ldr r2, [fp, #-20]
rsb r3, r2, r3
cmp r3, #0
bge .L3
mov r0, #1
b .L2
b .L4
.L3:
mov r0, #0
b .L2
.L4:
.L2:
ldmea fp, {fp, sp, pc}
.Lfe1:
.size testa,.Lfe1-testa
.align 2
.global testb
.type testb,function
testb:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, current_function_anonymous_args = 0
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
sub sp, sp, #8
str r0, [fp, #-16]
str r1, [fp, #-20]
ldr r3, [fp, #-16]
ldr r2, [fp, #-20]
cmp r3, r2
bge .L6
mov r0, #1
b .L5
b .L7
.L6:
mov r0, #2
b .L5
.L7:
.L5:
ldmea fp, {fp, sp, pc}
.Lfe2:
.size testb,.Lfe2-testb
------------------------------------------------
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: target/1947: gcc for target xscale generates incorrect code when optimization is turned on
@ 2001-04-01 0:00 Richard Earnshaw
0 siblings, 0 replies; 2+ messages in thread
From: Richard Earnshaw @ 2001-04-01 0:00 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR target/1947; it has been noted by GNATS.
From: Richard Earnshaw <rearnsha@arm.com>
To: vmoorthy@giganet.com
Cc: gcc-gnats@gcc.gnu.org, jimw@giganet.com, Richard.Earnshaw@arm.com
Subject: Re: target/1947: gcc for target xscale generates incorrect code
when optimization is turned on
Date: Mon, 12 Feb 2001 16:09:27 +0000
The release number (2.9-xscale-001130) does not look like an FSF release
-- where did you get this compiler from?
I cannot reproduce this from the FSF CVS tree. Both with and without
xscale enabled, I get
testa:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, current_function_anonymous_args = 0
@ link register save eliminated.
rsb r0, r1, r0
mov r0, r0, lsr #31
mov pc, lr
.Lfe1:
.size testa,.Lfe1-testa
.align 2
.global testb
.type testb,function
testb:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, current_function_anonymous_args = 0
@ link register save eliminated.
cmp r0, r1
movge r0, #2
movlt r0, #1
mov pc, lr
.Lfe2:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-04-01 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-01 0:00 target/1947: gcc for target xscale generates incorrect code when optimization is turned on vmoorthy
2001-04-01 0:00 Richard Earnshaw
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).