<html>
    <head>
      <base href="http://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: Negative offset support problem"
   href="http://llvm.org/bugs/show_bug.cgi?id=20853">20853</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ARM: Negative offset support problem
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </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>llc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ioblakov@dev.rtsoft.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12990" name="attach_12990" title="Test">attachment 12990</a> <a href="attachment.cgi?id=12990&action=edit" title="Test">[details]</a></span>
Test

ARM compiler can use negative offset (imm12) only for a frame access. 

The following example (n.c) shows problem:

int sum(int *p)
{
    return p[-4] + p[-2] + p[0] + p[2] + p[4];
}

clang --target=arm -mcpu=cortex-a9 -S -mfloat-abi=soft -O3 n.c

sum:
    sub    r1, r0, #16 <<< instead of using [r0, #-16] to load a p[-4]
    sub    r2, r0, #8  <<< instead of using [r0, #-8] to load a p[-2]
    ldr    r1, [r1]
    ldr    r2, [r2]
    ldr    r3, [r0, #8]
    add    r1, r2, r1
    ldr    r2, [r0]
    ldr    r0, [r0, #16]
    add    r1, r1, r2
    add    r1, r1, r3
    add    r0, r1, r0
    bx    lr</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>