<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - ARM: integrated assembler should replace "ldr rX, =imm" with "mov rX, #imm" if imm can be encoded as immediate"
   href="https://llvm.org/bugs/show_bug.cgi?id=25722">25722</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ARM: integrated assembler should replace "ldr rX, =imm" with "mov rX, #imm" if imm can be encoded as immediate
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: ARM
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>gas does that, it produces smaller code, and it prevents follow-on "out of
range pc-relative fixup value" errors if the ldr is in a large-ish code block
and the offset to the constant pool is too large.

Example (reduced from boringssl):

thakis@thakis:~/src/chrome/src$ head arm.S
.fpu neon
.text
.align 4
.global foo
.hidden foo
.type foo, %function

ldr r4, =0
mov r1, r2
mov r1, r2
/* repeat previous instruction 2000 times here */

thakis@thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c arm.S -march=armv7-a 
-target arm-linux-androideab
arm.S:8:1: error: out of range pc-relative fixup value
ldr r4, =0
^
thakis@thakis:~/src/chrome/src$
third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
-c arm.S
thakis@thakis:~/src/chrome/src$
third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump
-D -marm arm.o  | head

arm.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <.text>:
       0:    e3a04000     mov    r4, #0
       4:    e1a01002     mov    r1, r2
       8:    e1a01002     mov    r1, r2</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>