[Bug target/53949] [SH] Add support for mac.w / mac.l instructions

olegendo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 30 19:37:00 GMT 2015


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

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-01-30
     Ever confirmed|0                           |1

--- Comment #12 from Oleg Endo <olegendo at gcc dot gnu.org> ---
This is an example from Renesas public material regarding the SH-DSP.  The
example program can utilize either the regular mac.w instruction, or the DSP
ISA (found on SH2-DSP, SH3-DSP, SH4AL-DSP).

typedef short  Fixed;
typedef long Lfixed;
typedef long Laccum;
#define __X
#define __Y

void func(__X Fixed x[5],Fixed *out, __Y Fixed y[128][5] )
{
  int i;
  __Y Fixed *yp=y[0];
  __X Fixed *xp=x;
  Fixed x0,y0;
  Lfixed m0;
  Laccum a0;
  for(i=0;i<128;i++)
  {
    a0=0;
    x0=*xp++; y0=*yp++;
    m0=x0*y0; x0=*xp++; y0=*yp++;
    a0+=m0; m0=x0*y0; x0=*xp++; y0=*yp++;
    a0+=m0; m0=x0*y0; x0=*xp++; y0=*yp++;
    a0+=m0; m0=x0*y0; x0=*xp++; y0=*yp++;
    a0+=m0; m0=x0*y0; 
    a0+=m0;
    *out++=a0;
  }
}

which should compile to something like:
_func:
        mov     #-128,r1
        mov     r5,r3
        extu.b  r1,r1
.L11:
        clrmac
        mac.w   @r6+,@r4+
        dt      r1
        mac.w   @r6+,@r4+
        mac.w   @r6+,@r4+
        mac.w   @r6+,@r4+
        sts     macl,r2
        mov.w   r2,@r3
        bf/s    .L11
        add     #2,r3

        rts
        nop



More information about the Gcc-bugs mailing list