[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 20 12:36:07 PDT 2018
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 i128
%c = shl i128 %b, 64
%d = or i128 %a, %c
%amtmask = and i8 %amt, 63
%e = zext i8 %amtmask to i128
%f = shl i128 %d, %e
%g = lshr i128 %f, 64
%h = trunc i128 %g to i64
ret i64 %h
}
define i64 @__shiftright128(i64 %x, i64 %y, i8 %amt) {
%a = zext i64 %x to i128
%b = zext i64 %y to i128
%c = shl i128 %b, 64
%d = or i128 %a, %c
%amtmask = and i8 %amt, 63
%e = zext i8 %amtmask to i128
%f = lshr i128 %d, %e
%g = trunc i128 %f to i64
ret i64 %g
}
https://reviews.llvm.org/D49606
More information about the cfe-commits
mailing list