[Bug c/48090] New: gcc 4.5.2 miscompilation when building on arm
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48090 Summary: gcc 4.5.2 miscompilation when building on arm Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: arnaud.pat...@rtp-net.org With gcc-4.5.2, even with gcc-4.5-20110310, the following line of code gets miscompiled (See attachment) : size -= nblk * 512; size and nblk are 64 bits. gcc tries to compute -nblk. nblk is stored in r0,r1. gcc produces the following asm code : rsbsr1, r0, #0 rsc r2, r1, #0 So r1 gets corrupted by the rsbs insn, thus getting wrong value in r2. I'm building the asm code with : gcc -O2 -march=armv5t list2.i -o - -S When I use : gcc -O2 -fno-cse-follow-jumps -march=armv5t list2.i -o - -S I get : rsbsr0, r0, #0 rsc r1, r1, #0 which is fine.
[Bug c/48090] gcc 4.5.2 miscompilation when building on arm
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48090 --- Comment #1 from arnaud patard 2011-03-12 09:02:30 UTC --- Created attachment 23636 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23636 test file
[Bug c/48090] gcc 4.5.2 miscompilation when building on arm
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48090 --- Comment #3 from arnaud patard 2011-03-12 12:16:12 UTC --- (In reply to comment #2) > I get correct-looking code on armv5tel-linux with vanilla gcc-4.6-20110305 and > gcc-4.5-20110310, with 4.4 the code looks different but not obviously broken. I said -march=armv5t (or -march=armv4t I guess). It's important as -march=armv5te won't trigger the bug. > > Can you make the test case standalone and include a runtime check for the > possible miscompilation? My test case was to build tar and run the delete01.at check but it's not really a standalone test. So far, I've not managed to have a test case small than compiling the preprocessed file. > > How was your gcc configured? I reproduce it with my gcc and debian gcc 4.5.2 so I believe this rules out misconfiguration.
[Bug c/48090] gcc 4.5.2 miscompilation when building on arm
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48090 --- Comment #9 from arnaud patard 2011-03-13 20:40:27 UTC --- I confirm that backporting r159644 and r159683 make things work. From comment 8, I guess that the bug is still there and that one can still hit it sooner or later, right ? (btw, amazing job)