<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Opus miscompiled for ARM after ParallelDSP change r367389"
   href="https://bugs.llvm.org/show_bug.cgi?id=43073">43073</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Opus miscompiled for ARM after ParallelDSP change r367389
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, sam.parker@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Some WebRTC tests which use Opus started failing on Android after LLVM r367389
(<a href="https://bugs.chromium.org/p/webrtc/issues/detail?id=10887">https://bugs.chromium.org/p/webrtc/issues/detail?id=10887</a>)

It's very possible that the change itself is fine, but that it exposed
ParallelDSP to more code that then got miscompiled due to some already existing
bug in the pass.


Here's a reduced repro which I think shows the problem:


b.c:

typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;

#define MLA(a, m, n) (int32_t)((uint32_t)(a) + (uint32_t)((int32_t)(int16_t)(m)
* (int32_t)(int16_t)(n)))

int32_t bar(int32_t a, int32_t b);

int32_t foo(const int16_t *in, const int16_t *b)
{
  uint32_t x;

  x = bar(in[0], b[0]);

  x = MLA(x, in[-1], b[1]);
  x = MLA(x, in[-2], b[2]);
  x = MLA(x, in[-3], b[3]);
  x = MLA(x, in[-4], b[4]);
  x = MLA(x, in[-5], b[5]);

  return x;
}

$ clang --target=arm-linux-androideabi -march=armv7-a -mthumb
-fomit-frame-pointer -O3 -S /tmp/b.c -o -
[...]
foo:
        .fnstart
@ %bb.0:                                @ %entry
        .save   {r4, r5, r7, lr}
        push    {r4, r5, r7, lr}
        mov     r4, r1
        mov     r5, r0
        ldrsh.w r1, [r1]
        ldrsh.w r0, [r0]
        bl      bar
        ldr     r2, [r5, #-4]
        ldr.w   r3, [r4, #2]
        ldr     r1, [r5, #-8]
        ldr.w   r5, [r4, #6]
        smlabt  r0, r3, r2, r0
        smladx  r0, r3, r2, r0
        smladx  r0, r5, r1, r0
        pop     {r4, r5, r7, pc}
.Lfunc_end0:
        .size   foo, .Lfunc_end0-foo
        .cantunwind
        .fnend


My ARM/Thumb is rusty, but it appears that both the SMLABT and the first SMLADX
instruction are accumulating in[-1] * b[1] into r0, and that in[-5] and b[5]
are never even loaded.</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>