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

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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 ` pinskia at gcc dot gnu dot org
  2010-06-03 18:18 ` kazu at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-06-03 17:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2010-06-03 17:27 -------
Looks related to PR 20972.


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: kazu at gcc dot gnu dot org @ 2010-06-03 18:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kazu at gcc dot gnu dot org  2010-06-03 18:18 -------
Andrew,

auto-inc-dec.c was introduced on Jul 2, 2006, and PR 20972 was filed
on April 12, 2005, so I'd think that PR 20972 is due to something
else.  They do both involve the same assembler message though.


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-06-03 18:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2010-06-03 18:25 -------
(In reply to comment #2)
> auto-inc-dec.c was introduced on Jul 2, 2006, and PR 20972 was filed
> on April 12, 2005, so I'd think that PR 20972 is due to something
> else.  They do both involve the same assembler message though.

Yes but if you read that PR you will notice that auto-inc-dec.c included some
of the same issues as flow did.


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: kazu at gcc dot gnu dot org @ 2010-06-07 11:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from kazu at gcc dot gnu dot org  2010-06-07 11:35 -------
Posted a patch.


-- 

kazu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2010-
                   |                            |06/msg00514.html


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (3 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: kazu at gcc dot gnu dot org @ 2010-06-07 13:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from kazu at gcc dot gnu dot org  2010-06-07 13:12 -------
Subject: Bug 44404

Author: kazu
Date: Mon Jun  7 13:12:42 2010
New Revision: 160372

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160372
Log:
gcc/
        PR rtl-optimization/44404
        * auto-inc-dec.c (find_inc): Use reg_overlap_mentioned_p instead
        of count_occurrences to see if it's safe to modify mem_insn.insn.
        gcc/testsuite/

gcc/testsuite/
        PR rtl-optimization/44404
        * gcc.dg/pr44404.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/pr44404.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/auto-inc-dec.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (4 preceding siblings ...)
  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
  7 siblings, 0 replies; 10+ messages in thread
From: kazu at gcc dot gnu dot org @ 2010-06-07 13:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from kazu at gcc dot gnu dot org  2010-06-07 13:15 -------
Fixed.


-- 

kazu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (5 preceding siblings ...)
  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
  7 siblings, 0 replies; 10+ messages in thread
From: kazu at gcc dot gnu dot org @ 2010-06-07 13:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from kazu at gcc dot gnu dot org  2010-06-07 13:17 -------
Subject: Bug 44404

Author: kazu
Date: Mon Jun  7 13:17:32 2010
New Revision: 160374

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160374
Log:
gcc/
        PR rtl-optimization/44404
        * auto-inc-dec.c (find_inc): Use reg_overlap_mentioned_p instead
        of count_occurrences to see if it's safe to modify mem_insn.insn.
        gcc/testsuite/

gcc/testsuite/
        PR rtl-optimization/44404
        * gcc.dg/pr44404.c: New.

Modified:
    trunk/gcc/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
  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
                   ` (6 preceding siblings ...)
  2010-06-07 13:17 ` kazu at gcc dot gnu dot org
@ 2010-07-07 15:27 ` bernds at gcc dot gnu dot org
  7 siblings, 0 replies; 10+ messages in thread
From: bernds at gcc dot gnu dot org @ 2010-07-07 15:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from bernds at gcc dot gnu dot org  2010-07-07 15:27 -------
Subject: Bug 44404

Author: bernds
Date: Wed Jul  7 15:26:48 2010
New Revision: 161920

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161920
Log:
        PR rtl-optimization/44404
        * auto-inc-dec.c (find_inc): Avoid calling count_occurrences if
        possible, use reg_overlap_mentioned_p instead.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/auto-inc-dec.c


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug rtl-optimization/44404] auto-inc-dec generates an invalid assembly instruction
       [not found] <bug-44404-4@http.gcc.gnu.org/bugzilla/>
@ 2015-02-19 11:34 ` cbaylis at gcc dot gnu.org
  0 siblings, 0 replies; 10+ messages in thread
From: cbaylis at gcc dot gnu.org @ 2015-02-19 11:34 UTC (permalink / raw)
  To: gcc-bugs

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

cbaylis at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gilles.chanteperdrix@xenoma
                   |                            |i.org

--- Comment #9 from cbaylis at gcc dot gnu.org ---
*** Bug 38674 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 10+ messages in thread

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