[llvm-bugs] [Bug 41301] New: Optimizer fails to generate SIB displacements in arithmetic expressions (x86_64)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 29 05:52:10 PDT 2019


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

            Bug ID: 41301
           Summary: Optimizer fails to generate SIB displacements in
                    arithmetic expressions (x86_64)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bisqwit at iki.fi
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Consider this example code.

    unsigned test(unsigned a,unsigned b)
    {
        return a*4 + b - 1;
    }

GCC and ICC optimize this into a single instruction:

    lea eax, [rsi + rdi*4 - 1]

However, Clang generates two instructions, no matter which optimization level
(tried -O3, -Os, -Ofast):

    lea eax, [rsi + rdi*4]
    add eax, -1

Not only is the latter longer in terms of instructions, it is longer in terms
of opcodes as well (4 bytes versus 6).

Same happens on both negative and positive displacements.

-- 
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/20190329/37e977ce/attachment.html>


More information about the llvm-bugs mailing list