[llvm-bugs] [Bug 41164] New: Code generation for 128 bit multiplication - MULX

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 20 18:23:50 PDT 2019


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

            Bug ID: 41164
           Summary: Code generation for 128 bit multiplication - MULX
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

uint64_t wyhash64_x; 


uint64_t wyhash64() {
  wyhash64_x += 0x60bee2bee120fc15;
  __uint128_t tmp;
  tmp = (__uint128_t) wyhash64_x * 0xa3b195354a39b70d;
  uint64_t m1 = (tmp >> 64) ^ tmp;
  tmp = (__uint128_t)m1 * 0x1b03738712fad5c9;
  uint64_t m2 = (tmp >> 64) ^ tmp;
  return m2;
}

Clang trunk -O3 -march=haswell
wyhash64():                           # @wyhash64()
        movabs  rcx, 6971258582664805397
        add     rcx, qword ptr [rip + wyhash64_x]
        mov     qword ptr [rip + wyhash64_x], rcx
        movabs  rsi, -6651371118538410227
        mov     rax, rcx
        mul     rsi
        imul    rcx, rsi
        xor     rcx, rdx
        movabs  rdx, 1946526487930394057
        mov     rax, rcx
        mul     rdx
        xor     rax, rdx
        ret
wyhash64_x:
        .quad   0      


While ICC and GCC generates nicer code:

wyhash64():
        mov       rdx, 0x60bee2bee120fc15                       #10.3
        add       rdx, QWORD PTR wyhash64_x[rip]                #10.3
        mov       rax, 0xa3b195354a39b70d                       #12.3
        mov       QWORD PTR wyhash64_x[rip], rdx                #10.3
        mov       rsi, 0x1b03738712fad5c9                       #14.3
        mulx      rdx, rcx, rax                                 #12.36
        xor       rdx, rcx                                      #13.31
        mulx      rax, rdi, rsi                                 #14.27
        xor       rax, rdi                                      #15.31
        ret

-- 
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/20190321/adffea76/attachment-0001.html>


More information about the llvm-bugs mailing list