<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 --- - Missed optimizations for atomicrmw"
   href="http://llvm.org/bugs/show_bug.cgi?id=16477">16477</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed optimizations for atomicrmw
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>matthew@dempsky.org
          </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>Given this sample code:

  @x = global i32 0, align 4
  @y = global i32 0, align 4

  define void @doit() #0 {
  entry:
    %0 = atomicrmw add i32* @x, i32 2 monotonic
    %1 = atomicrmw add i32* @y, i32 2 monotonic
    %2 = atomicrmw add i32* @x, i32 2 monotonic
    %3 = atomicrmw add i32* @y, i32 2 monotonic
    ret void
  }

it should optimized into this:

  @x = global i32 0, align 4
  @y = global i32 0, align 4

  define void @doit() #0 {
  entry:
    %0 = atomicrmw add i32* @x, i32 4 monotonic
    %1 = atomicrmw add i32* @y, i32 4 monotonic
    ret void
  }

(or with the two atomicrmw's in the opposite order)

The critical things to note are that monotonic atomicrmws are allowed to be
interleaved with other instructions that can't alias (which LLVM should be able
to determine for @x and @y), and that monotonic atomicrmws to the same address
are allowed to be merged into a single instruction.</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>