<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 - WebRTC miscompile after ARMCodeGenPrepare was enabled"
   href="https://bugs.llvm.org/show_bug.cgi?id=39060">39060</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WebRTC miscompile after ARMCodeGenPrepare was enabled
          </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>llvm-bugs@lists.llvm.org, sam.parker@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following:

  typedef unsigned short uint16_t;

  uint16_t a = 0xFFFF;
  uint16_t b = 0;

  void f();
  void g();

  void test() {
    if (a != static_cast<uint16_t>(b-1)) {
      f();  // Shouldn't reach this point.
    } else {
      g();
    }
  }

With clang+llvm at r341931

$ clang -S -o - --target=arm-linux-androideabi -Oz /tmp/a.cc -mthumb
-march=armv7-a -mfloat-abi=softfp -mtune=generic-armv7-a -mfpu=neon

...
        ldrh    r0, [r0]
        ldrh    r1, [r1]
        subs    r0, #1    <--- subtract
        uxth    r0, r0    <--- truncate to 16-bit
        cmp     r1, r0    <--- compare
        it      eq
        beq     _Z1gv
        b       _Z1fv
...

At r341932:

...
        ldrh    r0, [r0]
        ldrh    r1, [r1]
        subs    r0, #1
        cmp     r1, r0
        it      eq
        beq     _Z1gv
        b       _Z1fv
...

The UXTH instruction has gone missing. The comparison will fail because it's
comparing 0xFFFFFFFF (32-bit -1) against 0xFFFF.


Chromium ran into this when running WebRTC tests on Android.</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>