[LLVMbugs] [Bug 5247] New: llc: cmp is moved over atomic add which DOES modify flags!

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Oct 19 03:02:31 PDT 2009


           Summary: llc: cmp is moved over atomic add which DOES modify
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=3672)
 --> (http://llvm.org/bugs/attachment.cgi?id=3672)

This code:
 %6 = call i64 @llvm.atomic.load.add.i64.p0i64(i64* getelementptr inbounds
([1216 x i64]* @__profiling_callsite_timestamps_live, i32 0, i32 51), i64 %5)
nounwind ; <i64> [#uses=0]
  %cmp = icmp eq i32 %3, 0                        ; <i1> [#uses=1]
  br i1 %cmp, label %if.then, label %if.end

Is compiled to this:
        cmpl    $0, %esi
        addq    %rdx, __profiling_callsite_timestamps_live+408(%rip)
        jne     .LBB1_4

If I run that code, the wrong branch is taken, because addq DOES modify the
flags, so you can't move a cmp before it.
If I edit the .s file and move the cmp after it, then its all OK.

Initially bugpoint reduced this as an -inline bug, but is really a llc bug,
which only occurs on the inlined code (the original code has a ret after the
addq, so this situation didn't occur).

The definition looks OK to me, it says that EFLAGS is modified, right?
let Constraints = "$val = $dst" in {
let Defs = [EFLAGS] in
def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins
               "xadd\t$val, $ptr",
               [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>,
                TB, LOCK;

This only occurs at llc -O1 and above.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list