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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to