public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/44404]  New: auto-inc-dec generates an invalid assembly instruction
@ 2010-06-03 17:21 kazu at gcc dot gnu dot org
  2010-06-03 17:27 ` [Bug rtl-optimization/44404] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: kazu at gcc dot gnu dot org @ 2010-06-03 17:21 UTC (permalink / raw)
  To: gcc-bugs

Consider:

char buf[128];

extern void bar (int a, const char *p);
extern char *strcpy (char *, const char *);

void
foo (int a)
{
  if (a)
    bar (0, buf);
  strcpy (buf, "0123456789abcdefghijklmnopqrstuvwxyz");
  bar (0, buf);
}

Compile this testcase with arm-none-linux-gnueabi-4.4.

strcpy above is inlined and unrolled like so:

        ldmia   r4!, {r0, r1, r2, r3}
        stmia   ip!, {r0, r1, r2, r3}
        ldmia   r4!, {r0, r1, r2, r3}
        stmia   ip!, {r0, r1, r2, r3}
        ldmia   r4, {r0, r1}
        str     r0, [ip], #4
        mov     r1, ip
        strb    r1, [r1], #-36

Notice that the last instruction looks strange.  R1 immediately after
the last ldmia contains the last character, namely the null
terminator, but that gets destroyed in "mov r1, ip".  Then strb
attempts to write r1 to the memory location pointed to by r1, which
doesn't make sense.

The last instruction comes from auto-inc-dec.c.

I've got a patch in testing.


-- 
           Summary: auto-inc-dec generates an invalid assembly instruction
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: kazu at gcc dot gnu dot org
        ReportedBy: kazu at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-none-linux-gnueabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44404


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-44404-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-02-19 11:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-03 17:21 [Bug rtl-optimization/44404] New: auto-inc-dec generates an invalid assembly instruction kazu at gcc dot gnu dot org
2010-06-03 17:27 ` [Bug rtl-optimization/44404] " pinskia at gcc dot gnu dot org
2010-06-03 18:18 ` kazu at gcc dot gnu dot org
2010-06-03 18:25 ` pinskia at gcc dot gnu dot org
2010-06-07 11:36 ` kazu at gcc dot gnu dot org
2010-06-07 13:13 ` kazu at gcc dot gnu dot org
2010-06-07 13:15 ` kazu at gcc dot gnu dot org
2010-06-07 13:17 ` kazu at gcc dot gnu dot org
2010-07-07 15:27 ` bernds at gcc dot gnu dot org
     [not found] <bug-44404-4@http.gcc.gnu.org/bugzilla/>
2015-02-19 11:34 ` cbaylis at gcc dot gnu.org

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