[LLVMbugs] [Bug 3701] New: optimization bug at -O2

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Mar 2 10:43:19 PST 2009


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

           Summary: optimization bug at -O2
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rdivacky at freebsd.org
                CC: llvmbugs at cs.uiuc.edu


hi.. when compiling the attached test case I am getting attached asm output.
here's a snippet of it:

<C code>
        if (pq->curr == xfer) {
                /* we are currently scheduled for callback */
                USB_BUS_UNLOCK(xfer->xroot->bus);
                return (1);
        }
        /* we are not pending */
        USB_BUS_UNLOCK(xfer->xroot->bus);
        return (0);
</C code>

(in the actual test case this is run  through ccc -E so it's expanded)

this is translated to this asm via "ccc -O2 -S -ffreestanding usb.c" (note that
the -O2 is important) to this (snippet):

<ASM code>
  (1)   cmpq    %rbx, 56(%rax)
        #APP
        movl %fs:0,%rax
        #NO_APP
        movq    104(%rbx), %rcx
        movq    296(%rcx), %rcx
        movl    $4, %edx
        #APP
  (2)  lock ;  cmpxchgl %edx,736(%rcx) ;  sete %al ;          1:               
              # atomic_cmpset_int

</ASM code>

note that the result of the cmpq at (1) is never used. and this cmpq
corresponds to the "if (pq->curr == xfer)" above. thus 1 is always returned.


-- 
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