================
@@ -12078,6 +12080,54 @@ static bool evalPackBuiltin(const CallExpr *E,
EvalInfo &Info, APValue &Result,
return true;
}
+static bool EvaluatePSADBW128(const CallExpr *E, EvalInfo &Info, APValue
&Result) {
+ // 1) Evaluate the arguments into APValues
+ APValue A, B;
+ if (!Evaluate(A, Info, E->getArg(0)) ||
+ !Evaluate(B, Info, E->getArg(1)))
+ return false;
+
+ if (!A.isVector() || !B.isVector())
+ return false;
+
+ unsigned Len = A.getVectorLength();
+ if (Len != 16) // psadbw128 uses 16 bytes (2 × 8)
+ return false;
+
+ // 2) Compute SAD over two 8-byte blocks
+ uint64_t Sum0 = 0;
+ uint64_t Sum1 = 0;
+
+ // bytes 0..7
+ for (unsigned i = 0; i < 8; ++i) {
+ uint64_t a = A.getVectorElt(i).getInt().getZExtValue();
+ uint64_t b = B.getVectorElt(i).getInt().getZExtValue();
+ Sum0 += (a > b ? a - b : b - a);
+ }
----------------
RKSimon wrote:
Use APIntOps::abdu ?
https://github.com/llvm/llvm-project/pull/169253
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits