r337619 - [ms] Add __shiftleft128 / __shiftright128 intrinsics
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 20 14:02:09 PDT 2018
Author: nico
Date: Fri Jul 20 14:02:09 2018
New Revision: 337619
URL: http://llvm.org/viewvc/llvm-project?rev=337619&view=rev
Log:
[ms] Add __shiftleft128 / __shiftright128 intrinsics
Carefully match the pattern matched by ISel so that this produces shld / shrd
(unless Subtarget->isSHLDSlow() is true).
Thanks to Craig Topper for providing the LLVM IR pattern that gets successfully
matched.
Fixes PR37755.
Modified:
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/Headers/ms-intrin.cpp
Modified: cfe/trunk/lib/Headers/intrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=337619&r1=337618&r2=337619&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Fri Jul 20 14:02:09 2018
@@ -863,6 +863,20 @@ __nop(void) {
__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) {
+ unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l;
+ unsigned __int128 __res = __val << (__d & 63);
+ return (unsigned __int64)(__res >> 64);
+}
+static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
+__shiftright128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) {
+ unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l;
+ unsigned __int128 __res = __val >> (__d & 63);
+ return (unsigned __int64)__res;
+}
+#endif
/*----------------------------------------------------------------------------*\
|* Privileged intrinsics
Modified: cfe/trunk/test/Headers/ms-intrin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=337619&r1=337618&r2=337619&view=diff
==============================================================================
--- cfe/trunk/test/Headers/ms-intrin.cpp (original)
+++ cfe/trunk/test/Headers/ms-intrin.cpp Fri Jul 20 14:02:09 2018
@@ -42,6 +42,8 @@ void f() {
__stosw(0, 0, 0);
#ifdef _M_X64
+ __shiftleft128(1, 2, 3);
+ __shiftright128(1, 2, 3);
__movsq(0, 0, 0);
__stosq(0, 0, 0);
#endif
More information about the cfe-commits
mailing list