[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision. thakis added a comment. r337619, thanks! The hoisting point is a good one; will rewrite using funnelshift once that's possible :-) https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment. In https://reviews.llvm.org/D49606#1170448, @thakis wrote: > Isn't implementing this in plain old C the nicest approach anyhow, even once > funnel shift exists? No, the primary reason for creating the intrinsic is that we can’t guarantee that we’ll recognize the

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM. I'm inclined to let this go in now since we have a requested use for it. We can change it to funnel shift once we're confident in the backend.

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment. The only weird thing that I can really think of with the C version is that the 'and' on the shift amount might get hoisted out of a loop and not get dropped during isel. https://reviews.llvm.org/D49606 ___

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment. Isn't implementing this in plain old C the nicest approach anyhow, even once funnel shift exists? https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment. @spatel, yes its exactly funnel shift. I wasn't sure if we were ready for clang to create it yet or not. Can we let this go as is and change it to funnel shift once we have the variable case fixed in the backend? https://reviews.llvm.org/D49606

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment. Now with C builtins which get nicely optimized. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 156596. thakis edited the summary of this revision. https://reviews.llvm.org/D49606 Files: clang/lib/Headers/intrin.h clang/test/Headers/ms-intrin.cpp Index: clang/test/Headers/ms-intrin.cpp

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment. In https://reviews.llvm.org/D49606#1170278, @craig.topper wrote: > Here are the IR patterns for this that work. Not sure if we can do this > directly in C, we need a 128 bit type, but maybe we can emit it from > CGBuiltin.cpp? > > define i64 @__shiftleft128(i64 %x,

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment. I'd prefer the pattern over inline assembly. It'll give us more flexibility in the backend if we should be using some other instruction on different targets. https://reviews.llvm.org/D49606 ___ cfe-commits mailing

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment. We have __int128. If you think hitting the pattern is preferable to inline asm, I can try to give that a try, either via C or via CGBuiltin.cpp. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment. Here are the IR patterns for this that work. Not sure if we can do this directly in C, we need a 128 bit type, but maybe we can emit it from CGBuiltin.cpp? define i64 @__shiftleft128(i64 %x, i64 %y, i8 %amt) { %a = zext i64 %x to i128 %b = zext i64 %y to

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment. @spatel, should this ultimately use funnel shift? https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics

2018-07-20 Thread Nico Weber via Phabricator via cfe-commits
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