This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/5781: "-O -funroll-loops" breaks machine code output



>Number:         5781
>Category:       optimization
>Synopsis:       "-O -funroll-loops" breaks machine code output
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 25 19:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     jodaman@ee1.bradley.edu
>Release:        gcc version 3.0.4
>Organization:
>Environment:
Linux version 2.2.20 #1 Wed Feb 6 06:07:24 CST 2002
arch: i686
>Description:
Under certain conditions, the loop unrolling optimization
will yield faulty code.  The resulting code may overwrite
the bounds of an array in a loop.  Attached is a small test
case that will crash because of this problem.

Another problem test case is the LAME audio encoder
(http://lame.sourceforge.net/) with "-O3 -funroll-loops"
or "-O2 -funroll-loops" enabled.  The developers of LAME
are aware of the this gcc issue and have recently removed
"-funroll-loops" for all gcc version 3 compiles.

Disabling "-funroll-loops" until this problem is resolved
may be wise because of the nature of the problem.  In some
cases, GCC may silently overstep the bounds of an array
without any apparent immediate failure.  All code compiled
with optimization and "-funroll-loops" with GCC 3.0.3 or
3.0.4 is suspect.  (GCC 3.0.2 might not have this problem.)
>How-To-Repeat:
Test case fails (crashes):
 gcc-3.0.4 -O -funroll-loops test-O_unroll.c -o test; ./test

Test case completes:
 gcc-3.0.4 -O test-O_unroll.c -o test; ./test
>Fix:

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

LyoqCiAqIEBmaWxlICAgdGVzdC1PX3Vucm9sbC5jCiAqIEBhdXRob3IgSm9obiBEYWhsc3Ryb20g
PGpvZGFtYW5AZWUxLmJyYWRsZXkuZWR1PgogKgogKiB0ZXN0IGNhc2UgZm9yICItTyAtZnVucm9s
bC1sb29wcyIgYnVnIG9mIGdjYyAzLjAuMyBhbmQgMy4wLjQKICovCgppbnQgKmdldEEoKTsKaW50
ICoqZ2V0QigpOwoKaW50IG1haW4oKSB7CiAgaW50IHg7CiAgaW50IGk7CiAgaW50ICphICA9IGdl
dEEoKTsKICBpbnQgKipiID0gZ2V0QigpOyAKCiAgZm9yKCB4ID0gMDsgeCA8IDQ7IHgrKyApCiAg
ICBmb3IoIGkgPSAxOTsgLS1pID49IDA7ICkKICAgICAgaWYoYVtpXSA8IHgpCiAgICAgICAgYlt4
XVtpXSA9IHg7CgogIHJldHVybiAwOwp9CgpzdGF0aWMgaW50IGF6WzMyXSA9IHsgLTEsLTEsLTEs
LTEsIC0xLC0xLC0xLC0xLCAgMCwgMCwgMCwgMCwgIDEsIDEsIDEsIDEsCiAgICAgICAgICAgICAg
ICAgICAgICAgMSwgMiwgMiwgMiwgIDIsIDIsIDMsIDMsICAzLCA0LC0xLC0xLCAtMSwtMSwtMSwt
MSB9OwpzdGF0aWMgc3RydWN0IHsKICBpbnQgKmJbNF07CiAgaW50IGJiWzQgKiAzMl07Cn0gYno7
CgppbnQgKmdldEEoKSB7CiAgcmV0dXJuKCAmYXpbOF0gKTsKfQoKaW50ICoqZ2V0QigpIHsKICBp
bnQgaTsKICBmb3IoIGkgPSAwOyBpIDwgNDsgaSsrICkKICAgIGJ6LmJbaV0gPSAmYnouYmJbaSAq
IDMyXTsKICByZXR1cm4oIGJ6LmIgKTsKfQo=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]