https://sourceware.org/bugzilla/show_bug.cgi?id=18499

            Bug ID: 18499
           Summary: LDR immediate not using mov8 and mov.w for Thumb2
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: gas
          Assignee: unassigned at sourceware dot org
          Reporter: alessandro.marzocchi at gmail dot com
  Target Milestone: ---

Created attachment 8346
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8346&action=edit
patch

On thumb2 architecture (Cortex M4) the ldr Rx,=imm always translate to a ldr
from literal pool. This patch tries to correctly translate it to a mov8 or a
mov.w/mvn.w when possible. Please double check it as I have never done any
development on GAS source.

test assembly:
.thumb
.arch armv7-m
.syntax unified
.text

ldr r0,=4
ldr r0,=0xFF000000
ldr r0,=0xFFFFFFC0
ldr r0,=0x12345678

pre-patch:
00000000 <.text>:
   0:   4801            ldr     r0, [pc, #4]    ; (8 <.text+0x8>)
   2:   4802            ldr     r0, [pc, #8]    ; (c <.text+0xc>)
   4:   4802            ldr     r0, [pc, #8]    ; (10 <.text+0x10>)
   6:   4803            ldr     r0, [pc, #12]   ; (14 <.text+0x14>)
   8:   00000004        .word   0x00000004
   c:   ff000000        .word   0xff000000
  10:   ffffffc0        .word   0xffffffc0
  14:   12345678        .word   0x12345678

after-patch:
00000000 <.text>:
   0:   2004            movs    r0, #4
   2:   f04f 407f       mov.w   r0, #4278190080 ; 0xff000000
   6:   f06f 003f       mvn.w   r0, #63 ; 0x3f
   a:   4800            ldr     r0, [pc, #0]    ; (c <.text+0xc>)
   c:   12345678        .word   0x12345678

-- 
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to