public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/50749] New: SH Target: Post-increment addressing used only for first memory access
@ 2011-10-16 20:29 oleg.endo@t-online.de
  2011-10-16 23:34 ` [Bug target/50749] " kkojima at gcc dot gnu.org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: oleg.endo@t-online.de @ 2011-10-16 20:29 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50749
           Summary: SH Target: Post-increment addressing used only for
                    first memory access
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: oleg.endo@t-online.de
                CC: kkojima@gcc.gnu.org
            Target: sh*-*-*


Post-increment addressing is generated only for the first
memory access. Any subsequent memory access does not use 
post-increment addressing.
The following two functions are reduced examples and result
in the same code being generated.
The problem exists with any number of memory accesses > 1
and at any optimization level.


int test_0 (char* p, int c)
{
  int r = 0;
  r += *p++;
  r += *p++;
  r += *p++;
  return r;
}

int test_1 (char* p, int c)
{
  int r = 0;
  r += p[0];
  r += p[1];
  r += p[2];
  return r;
}

compiled with -fno-ivopts -Os -m4-single -ml ... 

    mov    r4,r1
    mov.b    @r1+,r0
    add    #2,r4
    mov.b    @r1,r1
    add    r1,r0
    mov.b    @r4,r1
    rts    
    add    r1,r0

This could be done better ...

    mov.b    @r4+,r0
    mov.b    @r4+,r1
    add    r1,r0
    mov.b    @r4+,r1
    rts    
    add    r1,r0



Another example with a loop:

int test_func_1 (char* p, int c)
{
  int r = 0;
  do
  {
    r += *p++;
    r += *p++;
  } while (--c);
  return r;
}

compiled with -fno-ivopts -Os -m4-single -ml ... 

    mov    #0,r0
.L5:
    mov    r4,r1
    mov.b    @r1+,r2
    dt    r5
    mov.b    @r1,r1
    add    r2,r0
    add    #2,r4
    bf/s    .L5
    add    r1,r0
    rts    
    nop

would be better as:

    mov    #0, r0
.L5:
    mov.b    @r4+, r1
    dt    r5
    mov.b    @r4+, r2
    add    r1, r0
    bf/s    .L5
    add    r2, r0

    rts
    nop




Using built-in specs.
COLLECT_GCC=sh-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sh-elf/4.7.0/lto-wrapper
Target: sh-elf
Configured with: ../gcc-trunk/configure --target=sh-elf --prefix=/usr/local
--enable-languages=c,c++ --enable-multilib --disable-libssp --disable-nls
--disable-werror --enable-lto --with-newlib --with-gnu-as --with-gnu-ld
--with-system-zlib
Thread model: single
gcc version 4.7.0 20111016 (experimental) (GCC)


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

end of thread, other threads:[~2015-09-17 19:45 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-16 20:29 [Bug target/50749] New: SH Target: Post-increment addressing used only for first memory access oleg.endo@t-online.de
2011-10-16 23:34 ` [Bug target/50749] " kkojima at gcc dot gnu.org
2011-10-17  0:33 ` kkojima at gcc dot gnu.org
2011-10-19  0:00 ` oleg.endo@t-online.de
2011-10-19 21:37 ` kkojima at gcc dot gnu.org
2011-10-30 12:37 ` oleg.endo@t-online.de
2011-10-30 13:54 ` oleg.endo@t-online.de
2011-10-30 23:37 ` kkojima at gcc dot gnu.org
2011-11-28 22:54 ` oleg.endo@t-online.de
2011-11-29  0:25 ` kkojima at gcc dot gnu.org
2011-12-30  2:14 ` oleg.endo@t-online.de
2011-12-30  3:36 ` kkojima at gcc dot gnu.org
2012-06-12  7:10 ` [Bug middle-end/50749] Auto-inc-dec does not find subsequent contiguous mem accesses olegendo at gcc dot gnu.org
2012-08-23 14:17 ` [Bug rtl-optimization/50749] " olegendo at gcc dot gnu.org
2013-06-22 12:22 ` olegendo at gcc dot gnu.org
2013-09-30  9:06 ` amker.cheng at gmail dot com
2013-10-03 10:47 ` olegendo at gcc dot gnu.org
2013-12-06 20:28 ` olegendo at gcc dot gnu.org
2013-12-24 22:55 ` steven at gcc dot gnu.org
2015-05-22 13:57 ` olegendo at gcc dot gnu.org
2015-09-17  9:00 ` urjaman at gmail dot com
2015-09-17 14:26 ` olegendo at gcc dot gnu.org
2015-09-17 19:45 ` urjaman at gmail dot com

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