[llvm-bugs] [Bug 50420] New: code compiled with -fwrapv is faster than without

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 20 10:25:56 PDT 2021


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

            Bug ID: 50420
           Summary: code compiled with -fwrapv is faster than without
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: jmuizelaar at mozilla.com
                CC: llvm-bugs at lists.llvm.org

The following compiles to:

int f(int param) {
    int result = 0;
    for (int i=param; i < param + 16; i++) {
        result += param;
    }
    return result;
}



f(int):                                  # @f(int)
        lea     eax, [rdi + 15]
        cmp     edi, eax
        cmovg   eax, edi
        sub     eax, edi
        add     eax, 1
        imul    eax, edi
        ret

with -fwrapv it becomes:

f(int):                                  # @f(int)
        mov     ecx, edi
        shl     ecx, 4
        xor     eax, eax
        cmp     edi, 2147483632
        cmovl   eax, ecx
        ret

with gcc it becomes:

f(int):
        mov     eax, edi
        sal     eax, 4
        ret

icc and msvc compile to something similar to gcc

-- 
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/20210520/e9e88d8e/attachment.html>


More information about the llvm-bugs mailing list