This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/8313: gcc 3.2 on -O2 and yields bad code for unsigned short argument
- From: awong at cs dot washington dot edu
- To: gcc-gnats at gcc dot gnu dot org
- Date: 22 Oct 2002 20:53:29 -0000
- Subject: optimization/8313: gcc 3.2 on -O2 and yields bad code for unsigned short argument
- Reply-to: awong at cs dot washington dot edu
>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=