This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/18750] New: i386/amd64 -O1 faulty assembly code
- From: "vlad902 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Dec 2004 03:19:09 -0000
- Subject: [Bug c/18750] New: i386/amd64 -O1 faulty assembly code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I've found that when using -O1 on a default install FreeBSD 5.3/i386 system with
gcc 3.4.2 (default) that using -O1 causes. I've been able to reproduce on a Red
Hat Linux/amd64 system with gcc 3.3.3. Specifically I've found that on i386 a
code statement of "while(mutex);" (where mutex is a global volatile int) without
-O1 specified gcc produces:
.L4:
cmpl $0, mutex
jne .L5
jmp .L4
.L5:
On the other hand gcc with -O1 specified produces:
cmpl $0, mutex
.p2align 2,,3
.L4:
je .L4
In this case the "je" instruction loops forever if mutex is initially 0 causing
unwanted behavior. I have attached a test case.
Use of higher values as arguments to -O also cause a freeze in the test case.
--
Summary: i386/amd64 -O1 faulty assembly code
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vlad902 at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-fbsdproj-freebsd
GCC host triplet: i386-fbsdproj-freebsd
GCC target triplet: i386-fbsdproj-freebsd
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18750