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

* [Bug target/52412] another unnecessary register move on arm
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-02-29 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-29
                 CC|                            |ramana at gcc dot gnu.org
     Ever Confirmed|0                           |1
      Known to fail|                            |4.7.0

--- Comment #1 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-02-29 11:41:00 UTC ---
Confirmed - looks like 4.6 gets this right.

ramana


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

* [Bug target/52412] another unnecessary register move on arm
  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
  2 siblings, 0 replies; 4+ messages in thread
From: amker.cheng at gmail dot com @ 2012-07-31 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

amker.cheng <amker.cheng at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amker.cheng at gmail dot
                   |                            |com

--- Comment #2 from amker.cheng <amker.cheng at gmail dot com> 2012-07-31 14:12:54 UTC ---
The register move insn is generated by cse2 pass, and after that, there is no
cprop pass till ira.
The two allocnos for r6/r3(the original pseudos) are conflict with each other,
though they contains same value and connected by move insn, IRA cannot allocate
same hard register for them.
Moveover, the case is compile with Os, where gcc does IRA in whole single
region, and live range cannot be split either.


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

* [Bug target/52412] another unnecessary register move on arm
  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
  2 siblings, 0 replies; 4+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2014-07-09  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

ktkachov at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ktkachov at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #3 from ktkachov at gcc dot gnu.org ---
Both trunk 4.10 and 4.8.3 generate:
t0m:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        ldr     r3, [r0, #4]
        movs    r1, #10
        push    {r4, r5, lr}
        ldr     r5, .L8
        uxtb    r2, r3
.L2:
        ldr     r4, [r0, #268]
        subs    r1, r1, #1
        eor     r4, r4, r2
        ldr     r4, [r5, r4, lsl #2]
        str     r4, [r0, #268]
        bne     .L2
        add     r3, r3, r0
        movs    r1, #1
        strb    r1, [r3, #12]
        ldr     r3, [r0, #8]
        cmp     r3, r1
        beq     .L5
        cmp     r3, #2
        beq     .L5
        pop     {r4, r5, pc}
.L5:
        ldr     r3, [r0]
        strb    r2, [r3]
        pop     {r4, r5, pc}
.L9:
        .align  2
.L8:
        .word   Table


No superfluous mov appears, so I think this can be closed now...


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