[LLVMbugs] [Bug 16477] New: Missed optimizations for atomicrmw

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 27 16:22:48 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16477

            Bug ID: 16477
           Summary: Missed optimizations for atomicrmw
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: matthew at dempsky.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130627/a8f60c53/attachment.html>


More information about the llvm-bugs mailing list