[LLVMbugs] [Bug 9723] New: suboptimal treatment of "rm" constraint in inline assembly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 14 07:02:11 PDT 2011


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

           Summary: suboptimal treatment of "rm" constraint in inline
                    assembly
           Product: clang
           Version: 2.9
          Platform: PC
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: avg at FreeBSD.org
                CC: llvmbugs at cs.uiuc.edu


It seems that clang prefers "m" in "rm" over "r" without substantial reasons
for that, at least in some cases.

In the following code:

static __inline u_int
popcnt(u_int mask)
{
        u_int   result;

        __asm __volatile("popcnt %1,%0" : "=r" (result) : "rm" (mask));
        return (result);
}

...

dummy += popcnt(random());

Return value from random() gets passed to popcnt assembly instruction via a
memory location.  If I change "rm" to "r" then the value is transparently
passed via eax, which is quite faster in clock cycle terms.  I think that clang
should have figured that out :)

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