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

            Bug ID: 70995
           Summary: [SH] rotcl usage results in bloaty code
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
  Target Milestone: ---
            Target: sh*-*-*

While the following:

unsigned int
test_14 (unsigned int a, int b, int c)
{
  bool r = b == c;
  return (a << 9) | r;
}

compiles to a minimal sequence (-m4 -O2):
        cmp/eq  r6,r5
        shll8   r4
        mov     r4,r0
        rts
        rotcl   r0


changing the input values a little:

unsigned int
test_15 (unsigned int a, int b, int c)
{
  bool r = b != c;
  return (a << 11) | r;
}

results in (-m4 -O2):
        cmp/eq  r6,r5
        movt    r1
        shll8   r4
        tst     r1,r1
        shll2   r4
        mov     r4,r0
        rts
        rotcl   r0

and on SH2A (has nott insn):
        shll8   r4
        cmp/eq  r6,r5
        shll2   r4
        mov     r4,r0
        nott
        rts
        rotcl   r0


It seems for certain parameters it's better to not use the rotcl insn if the
nott insn is not available, as it saves one insn: 

        shll8   r4
        cmp/eq  r6,r5
        shll2   r4
        mov     #-1,r0
        negc    r0,r0
        rts
        or      r4,r0

Reply via email to