<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 - Spill in LL/SC loop when using fast register allocator"
   href="https://bugs.llvm.org/show_bug.cgi?id=50780">50780</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Spill in LL/SC loop when using fast register allocator
          </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>enhancement
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>lkail@cn.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For llvm IR from pr25526
```
define {i64, i1} @foo(i64* %addr, i64 %desired, i64 %new) {
  %old = cmpxchg i64* %addr, i64 %desired, i64 %new seq_cst seq_cst
  ret {i64, i1} %old
}
```
Run with `llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff
-regalloc=fast < bug.ll |less`
We got spills in LL/SC loop
```
# %bb.0:
        std 5, -24(1)                           # 8-byte Folded Spill
        std 4, -16(1)                           # 8-byte Folded Spill
        std 3, -8(1)                            # 8-byte Folded Spill
        sync
L..BB0_1:                               # =>This Inner Loop Header: Depth=1
        ld 4, -8(1)                             # 8-byte Folded Reload
        ld 3, -16(1)                            # 8-byte Folded Reload
        ldarx 4, 0, 4
        cmpd    3, 4
        std 4, -32(1)                           # 8-byte Folded Spill
        bne     0, L..BB0_3
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
        ld 3, -24(1)                            # 8-byte Folded Reload
        ld 4, -8(1)                             # 8-byte Folded Reload
        stdcx. 3, 0, 4
        bne     0, L..BB0_1
        b L..BB0_4
L..BB0_3:
        ld 3, -32(1)                            # 8-byte Folded Reload
        ld 4, -8(1)                             # 8-byte Folded Reload
        stdcx. 3, 0, 4
```
Though it hasn't caused infinite loop yet, the size of granule hasn't specified
in POWER ISA, we should avoid spilling considering implementation of POWER ISA
might vary.</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>