public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/3464: simple comparision gives wrong result on -maix64 with any optimization
@ 2001-06-28 10:56 boncz
0 siblings, 0 replies; 3+ messages in thread
From: boncz @ 2001-06-28 10:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 3464
>Category: c
>Synopsis: simple comparision gives wrong result on -maix64 with any optimization
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jun 28 10:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Peter Boncz
>Release: gcc 2.95.2
>Organization:
>Environment:
AIX 4.3.3 on powerpc64
>Description:
(long long ANY < long long X=almost min_int) and
(long long ANY > long long ANY)
where ANY seems to be almost any signed 64bits integer, and X is some crucial signed long. Bug occurs when X < (32768 - (1<<30))
bug: the expression evaluates to 0 where it should to 1 when compiling with any optimiziation.
without optimization, it works.
I do not understand the generated assembly. it does strange things with 32768 and ORI, where I would expect simple comparions and AND.
>How-To-Repeat:
main(int argc, char** argv) {
int i = atoi(argv[1]);
long long l = (long long) i;
printf("%d\n", (l > -2147450880) && (l < 42));
printf("%d\n", (l > -2147450881) && (l < 42));
}
/*
Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95.2/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_LONG_LONG -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_LONG_LONG -Asystem(unix) -Asystem(aix) -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -D__64BIT__ -D_ARCH_PPC b.c b.i
GNU CPP version 2.95.2 19991024 (release)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95.2/../../../../powerpc-ibm-aix4.3.2.0/include
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95.2/../../../../include/g++-3
End of omitted list.
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95.2/cc1 b.i -quiet -dumpbase b.c -maix64 -O -version -fcse -o b.s
cc1: Invalid option `-fcse'
GNU C version 2.95.2 19991024 (release) (powerpc-ibm-aix4.3.2.0) compiled by GNU C version 2.95.2 19991024 (release).
*/
/*
.file "b.c"
.machine "ppc64"
.toc
.csect .text[PR],3
gcc2_compiled.:
__gnu_compiled_c:
.csect _b.rw_c[RO],3
.align 3
LC..0:
.byte "%d"
.byte 10, 0
.toc
LC..1:
.tc LC..0[TC],LC..0
.csect .text[PR],3
.align 2
.globl main
.globl .main
.csect main[DS],3
main:
.llong .main, TOC[tc0], 0
.csect .text[PR]
.main:
mflr 0
std 29,-24(1)
std 30,-16(1)
std 31,-8(1)
std 0,16(1)
stdu 1,-144(1)
mr 29,4
bl .__main
cror 31,31,31
ld 3,8(29)
bl .atoi
cror 31,31,31
mr 29,3
addis 9,29,0x7fff
addi 9,9,32767
lis 0,0x7fff
ori 0,0,32808
cmpld 7,9,0
cror 31,30,28
mfcr 4
rlwinm 4,4,0,1
ld 3,LC..1(2)
extsw 4,4
bl .printf
cror 31,31,31
addis 29,29,0x8000
addi 29,29,-32768
lis 0,0x7fff
ori 0,0,32809
cmpld 7,29,0
cror 31,30,28
mfcr 4
rlwinm 4,4,0,1
ld 3,LC..1(2)
extsw 4,4
bl .printf
cror 31,31,31
la 1,144(1)
ld 0,16(1)
mtlr 0
ld 29,-24(1)
ld 30,-16(1)
ld 31,-8(1)
blr
LT..main:
.long 0
.byte 0,0,32,65,128,3,2,0
.long 0
.long LT..main-.main
.short 4
.byte "main"
_section_.text:
.csect .data[RW],3
.long _section_.text
*/
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/3464: simple comparision gives wrong result on -maix64 with any optimization
@ 2001-09-30 12:33 dje
0 siblings, 0 replies; 3+ messages in thread
From: dje @ 2001-09-30 12:33 UTC (permalink / raw)
To: boncz, dje, gcc-bugs, gcc-prs
Synopsis: simple comparision gives wrong result on -maix64 with any optimization
State-Changed-From-To: analyzed->closed
State-Changed-By: dje
State-Changed-When: Sun Sep 30 12:33:36 2001
State-Changed-Why:
Fixed in GCC 3.0.2 and GCC 3.1
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3464&database=gcc
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/3464: simple comparision gives wrong result on -maix64 with any optimization
@ 2001-07-06 22:53 dje
0 siblings, 0 replies; 3+ messages in thread
From: dje @ 2001-07-06 22:53 UTC (permalink / raw)
To: boncz, dje, gcc-bugs, gcc-prs, nobody
Synopsis: simple comparision gives wrong result on -maix64 with any optimization
Responsible-Changed-From-To: unassigned->dje
Responsible-Changed-By: dje
Responsible-Changed-When: Fri Jul 6 22:53:56 2001
Responsible-Changed-Why:
PowerPc codegen
State-Changed-From-To: open->analyzed
State-Changed-By: dje
State-Changed-When: Fri Jul 6 22:53:56 2001
State-Changed-Why:
64-bit sign extension overflow
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3464&database=gcc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-09-30 12:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-28 10:56 c/3464: simple comparision gives wrong result on -maix64 with any optimization boncz
2001-07-06 22:53 dje
2001-09-30 12:33 dje
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).