[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 20 09:32:55 PDT 2018
thakis created this revision.
thakis added a reviewer: craig.topper.
cl.exe maps these to shld / shrd, so let's do the same. ISel has `Subtarget->isSHLDSlow()` to prevent use of these intrinsics on some machines, but honoring them feels a bit like trying to outsmart the intrinsics user, and there's n good way to get at that bit from here anyways.
Fixes PR37755.
(I tried for a while to implement this in C so that ISel could just do its thing, but couldn't hit the right pattern -- and ISel only does shld64, not shrd64, as far as I can tell.)
https://reviews.llvm.org/D49606
Files:
clang/lib/Headers/intrin.h
clang/test/Headers/ms-intrin.cpp
Index: clang/test/Headers/ms-intrin.cpp
===================================================================
--- clang/test/Headers/ms-intrin.cpp
+++ clang/test/Headers/ms-intrin.cpp
@@ -42,6 +42,8 @@
__stosw(0, 0, 0);
#ifdef _M_X64
+ __shiftleft128(1, 2, 3);
+ __shiftright128(1, 2, 3);
__movsq(0, 0, 0);
__stosq(0, 0, 0);
#endif
Index: clang/lib/Headers/intrin.h
===================================================================
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -853,6 +853,18 @@
__asm__ volatile ("nop");
}
#endif
+#if defined(__x86_64__)
+static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
+__shiftleft128(unsigned __int64 l, unsigned __int64 h, unsigned char d) {
+ __asm__ __volatile__ ("shldq %1, %2, %0" : "+r"(h) : "c"(d), "r"(l));
+ return h;
+}
+static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
+__shiftright128(unsigned __int64 l, unsigned __int64 h, unsigned char d) {
+ __asm__ __volatile__ ("shrdq %1, %2, %0" : "+r"(l) : "c"(d), "r"(h));
+ return l;
+}
+#endif
/*----------------------------------------------------------------------------*\
|* Privileged intrinsics
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49606.156519.patch
Type: text/x-patch
Size: 1152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180720/a9cb590e/attachment.bin>
More information about the cfe-commits
mailing list