<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 - [MIPS] unoptimized __atomic_compare_exchange hangs on Octeon"
   href="https://bugs.llvm.org/show_bug.cgi?id=32020">32020</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[MIPS] unoptimized __atomic_compare_exchange hangs on Octeon
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>4.0
          </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: MIPS
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>james410@cowgill.org.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi,

Testcase:
<span class="quote">> int main(void)
> {
>     volatile int obj = 1;
>     int x = obj;

>     __atomic_compare_exchange_n(&obj, &x, 0, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
> }</span >

Compiling with:
clang-4.0 -O0 test.c -otes

Running "test" hangs on Cavium Octeon machines. The bug does not occur if -O1
is used.

The generated assembly contains this loop:
<span class="quote">> .LBB0_1:
>         ld      $1, 16($fp)
>         ll      $2, 0($1)
>         lw      $3, 32($fp)
>         sw      $2, 12($fp)
>         bne     $2, $3, .LBB0_3
>         nop
>         lw      $1, 28($fp)
>         ld      $2, 16($fp)
>         sc      $1, 0($2)
>         beqz    $1, .LBB0_1
>         nop</span >

However the Octeon processor manual states that _any_ store will cause a
subsequent sc instruction to fail and therefore this above loop will never
complete on Octeon.

Thanks,
James</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>