public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/8313: gcc 3.2 on -O2 and yields bad code for unsigned short argument
@ 2002-10-22 13:56 awong
  0 siblings, 0 replies; only message in thread
From: awong @ 2002-10-22 13:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8313
>Category:       optimization
>Synopsis:       gcc 3.2 on -O2 and yields bad code for unsigned short argument
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 22 13:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Albert Wong
>Release:        unknown-1.0
>Organization:
>Environment:
gentoo linux 1.4 PPC (G4 Cube)
>Description:
This error occurs only on optimization level 2  When passing in an argument of type unsigned short = 65535, gcc3.2 on the ppc generates the code li 3,-1 which incorrectly sign extends the value in the register to a 32-bit -1 rather than a 16-bit -1.
>How-To-Repeat:
gcc -O2 test.c

./a.out

This will be an inifinite loop, though the code should terminate after 2 calls to "inf_loop".
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.c"

I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIEEgMHhmZmZmCgp0eXBlZGVmIHVuc2lnbmVkIHNo
b3J0IHUxNl90OwoKaW50IGluZl9sb29wKHUxNl90IHR5cGUpIHsKCglpZiggdHlwZSA9PSBBICkg
ewoJCWZwcmludGYoc3RkZXJyLCAiQnJlYWsgcmVjdXJzaW9uXG4iKTsKCQlyZXR1cm4gMDsKCX0K
CglmcHJpbnRmKHN0ZGVyciwgIlJlY3Vyc2lvblxuIik7CgoJcmV0dXJuIGluZl9sb29wKEEpOwp9
CgppbnQgbWFpbih2b2lkKSB7CglpbmZfbG9vcCgxKTsKCXJldHVybiAwOwp9Cgo=


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-22 20:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-22 13:56 optimization/8313: gcc 3.2 on -O2 and yields bad code for unsigned short argument awong

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).