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

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
        .quad   0      

While ICC and GCC generates nicer code:

        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

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to