[llvm-bugs] [Bug 38423] New: [X86][SSE] Add ISD::MULHS/MULHU vXi64 support

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 2 07:06:41 PDT 2018


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

            Bug ID: 38423
           Summary: [X86][SSE] Add ISD::MULHS/MULHU vXi64 support
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: andrea.dibiagio at gmail.com, craig.topper at gmail.com,
                    lebedev.ri at gmail.com, llvm-bugs at lists.llvm.org,
                    spatel+llvm at rotateright.com

I haven't thoroughly tested this but MULHU should be something like:

define <2 x i64> @mulh_2u64(<2 x i64>, <2 x i64>) {
  %3 = and <2 x i64> %0, <i64 4294967295, i64 4294967295>
  %4 = lshr <2 x i64> %0, <i64 32, i64 32>
  %5 = and <2 x i64> %1, <i64 4294967295, i64 4294967295>
  %6 = lshr <2 x i64> %1, <i64 32, i64 32>
  %7 = mul nuw <2 x i64> %6, %4
  %8 = mul nuw <2 x i64> %5, %4
  %9 = mul nuw <2 x i64> %6, %3
  %10 = mul nuw <2 x i64> %5, %3
  %11 = and <2 x i64> %8, <i64 4294967295, i64 4294967295>
  %12 = and <2 x i64> %9, <i64 4294967295, i64 4294967295>
  %13 = add nuw nsw <2 x i64> %11, %12
  %14 = lshr <2 x i64> %10, <i64 32, i64 32>
  %15 = add nuw nsw <2 x i64> %13, %14
  %16 = lshr <2 x i64> %15, <i64 32, i64 32>
  %17 = lshr <2 x i64> %8, <i64 32, i64 32>
  %18 = add <2 x i64> %17, %7
  %19 = lshr <2 x i64> %9, <i64 32, i64 32>
  %20 = add <2 x i64> %18, %19
  %21 = add <2 x i64> %20, %16
  ret <2 x i64> %21
}

mulh_2u64:
  vpxor %xmm2, %xmm2, %xmm2
  vpblendw $204, %xmm2, %xmm0, %xmm3 # xmm3 =
xmm0[0,1],xmm2[2,3],xmm0[4,5],xmm2[6,7]
  vpblendw $204, %xmm2, %xmm1, %xmm4 # xmm4 =
xmm1[0,1],xmm2[2,3],xmm1[4,5],xmm2[6,7]
  vpsrlq $32, %xmm0, %xmm0
  vpsrlq $32, %xmm1, %xmm1
  vpmuludq %xmm0, %xmm1, %xmm5
  vpmuludq %xmm3, %xmm1, %xmm1
  vpmuludq %xmm0, %xmm4, %xmm0
  vpmuludq %xmm3, %xmm4, %xmm3
  vpblendw $204, %xmm2, %xmm0, %xmm4 # xmm4 =
xmm0[0,1],xmm2[2,3],xmm0[4,5],xmm2[6,7]
  vpblendw $204, %xmm2, %xmm1, %xmm2 # xmm2 =
xmm1[0,1],xmm2[2,3],xmm1[4,5],xmm2[6,7]
  vpsrlq $32, %xmm0, %xmm0
  vpsrlq $32, %xmm3, %xmm3
  vpsrlq $32, %xmm1, %xmm1
  vpaddq %xmm2, %xmm4, %xmm2
  vpaddq %xmm5, %xmm0, %xmm0
  vpaddq %xmm3, %xmm2, %xmm2
  vpaddq %xmm1, %xmm0, %xmm0
  vpsrlq $32, %xmm2, %xmm2
  vpaddq %xmm2, %xmm0, %xmm0
  retq

-- 
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/20180802/9498068e/attachment.html>


More information about the llvm-bugs mailing list