================
@@ -3423,6 +3423,18 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
           return LHS.isSigned() ? LHS.ssub_sat(RHS) : LHS.usub_sat(RHS);
         });
 
+  case clang::X86::BI__builtin_ia32_pmulhrsw128:
+  case clang::X86::BI__builtin_ia32_pmulhrsw256:
+  case clang::X86::BI__builtin_ia32_pmulhrsw512:
+    return interp__builtin_elementwise_int_binop(
+        S, OpPC, Call, [](const APSInt &LHS, const APSInt &RHS) {
+          unsigned Width = LHS.getBitWidth();
+          APInt Mul = llvm::APIntOps::mulhs(LHS, RHS);
+          Mul = Mul.relativeLShr(14);
+          Mul = Mul + APInt(Width, 1, true);
+          return Mul.relativeLShr(1);
+        });
----------------
Temperz87 wrote:

I think this diverges from X86InstCombineIntrinsic.cpp where logical shifting 
is used instead of arithmetic, as well as extract bits being used in place of 
shifting to the right. I understand that this code has the exact same behavior 
but I just want to make sure that's alright 

Also should this change apply to ExprConstant as well?

https://github.com/llvm/llvm-project/pull/160636
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to