[llvm-bugs] [Bug 26291] New: MIPS back end performs inefficient subtraction of immediates

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 25 08:36:18 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26291

            Bug ID: 26291
           Summary: MIPS back end performs inefficient subtraction of
                    immediates
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: MIPS
          Assignee: unassignedbugs at nondot.org
          Reporter: csdavec at swan.ac.uk
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Simple C test case:

int foo(char*,char*, char*);

int main(void)
{
    char z[1048576];
    foo(z,z,z);
}

The key part of the IR:

%z = alloca [1048576 x i8], align 1

This produces the following code for the stack pointer modification:

    daddiu    $5, $zero, 1
    dsll    $5, $5, 44
    daddiu    $5, $5, -1
    dsll    $5, $5, 20
    daddiu    $5, $5, -48
    daddu    $sp, $sp, $5

This would be much simpler as

lui   $5, 16
dsubu $sp, $sp, $5

Even without rewriting the add as a subtraction, the constant could be
materialised as:

lui   $5, 16
dsubu $5, $zero, $5

-- 
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/20160125/257af104/attachment.html>


More information about the llvm-bugs mailing list