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

           Summary: Input constraints for inline assembler are not used
                    for CSE
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


Consider the following program:

static inline void
outb(unsigned short port, unsigned char data)
{
        __asm volatile("outb %%al,%w1" : : "a" (data), "d" (port));
}

extern unsigned short base;

void test(void)
{
        outb(base + 16, 0x0);
        outb(base + 16, 0x1);
        outb(base + 16, 0x2);
        outb(base + 16, 0x3);
        outb(base + 16, 0x4);
        outb(base + 16, 0x5);
        outb(base + 16, 0x6);
        outb(base + 16, 0x7);
        outb(base + 16, 0x8);
}

This should be compiled into something like:

movzwl base, %edx
add 0x10, %edx
xorl %eax, %eax
outb %al,%dx
movb $1, %al
outb %al,%dx
movb $2, %al
outb %al,%dx
...

or even better in terms of code size:

movzwl base, %edx
add 0x10, %edx
xorl %eax, %eax
outb %al,%dx
incl %eax
outb %al,%dx
incl %eax
outb %al,%dx
...

But currently it gets compiled to:

movzwl base, %edx
add 0x10, %edx
xorl %eax, %eax
outb %al,%dx
movzwl base, %edx
add 0x10, %edx
movb $1, %al
outb %al,%dx
movzwl base, %edx
add 0x10, %edx
movb $2, %al
outb %al,%dx
...

Input constraints are not clobbered and therefore, they don't have to be
reloaded. The reload overhead in this case is significant.

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to