public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/52412] New: another unnecessary register move on arm
@ 2012-02-28  9:01 carrot at google dot com
  2012-02-29 11:44 ` [Bug target/52412] " ramana at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: carrot at google dot com @ 2012-02-28  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52412
           Summary: another unnecessary register move on arm
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: carrot@google.com
            Target: arm-linux-gnueabi


Compile following code with options -march=armv7-a -mthumb -Os

extern int Table[256];
typedef struct {
      char* f0;
      int f1;
      int f2;
      char f3[256];
      int f4;
   } S;

void t0m(S* s)
{
   int i;
   char ch = (char)(s->f1);
   for (i = 0; i < 10 ; i++)
      s->f4 =  Table[s->f4 ^ ch];
   s->f3[s->f1] = 1;
   switch (s->f2) {
      case 1:
         *s->f0 = ch;
         break;
      case 2:
         *s->f0 = ch;
         break;
   }
}

ARM gcc 4.7 generates:


t0m:
    ldr    r1, [r0, #4]
    movs    r2, #10
    push    {r4, r5, r6, lr}
    uxtb    r3, r1
    ldr    r5, .L7
    mov    r6, r3                // A
.L2:
    ldr    r4, [r0, #268]
    subs    r2, r2, #1
    eor    r4, r6, r4
    ldr    r4, [r5, r4, lsl #2]
    str    r4, [r0, #268]
    bne    .L2
    adds    r1, r0, r1
    movs    r2, #1
    strb    r2, [r1, #12]
    ldr    r2, [r0, #8]
    cmp    r2, #1
    beq    .L5
    cmp    r2, #2
    bne    .L1
.L5:
    ldr    r2, [r0, #0]
    strb    r3, [r2, #0]
.L1:
    pop    {r4, r5, r6, pc}
.L8:
    .align    2
.L7:
    .word    Table

Instruction A moves register r3 to r6, but both r3 and r6 are read only in
following code, so any one is enough for following usage.

Compile it to arm mode instructions has the same problem.


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

end of thread, other threads:[~2014-07-09  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28  9:01 [Bug target/52412] New: another unnecessary register move on arm carrot at google dot com
2012-02-29 11:44 ` [Bug target/52412] " ramana at gcc dot gnu.org
2012-07-31 14:13 ` amker.cheng at gmail dot com
2014-07-09  8:42 ` ktkachov 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).