[clang] [WIP][Clang][bytecode] interp__builtin_elementwise_int_binop - allow RHS operand to be a scalar (PR #156017)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 29 06:46:00 PDT 2025
================
@@ -2565,21 +2565,48 @@ static bool interp__builtin_elementwise_int_binop(
return true;
}
+ const auto *VT = Call->getArg(0)->getType()->castAs<VectorType>();
+ assert(VT->getElementType()->isIntegralOrEnumerationType());
+ PrimType ElemT = *S.getContext().classify(VT->getElementType());
+ unsigned NumElems = VT->getNumElements();
+
+ // Vector + Scalar case.
+ if (!Call->getArg(1)->getType()->isVectorType()) {
+ assert(Call->getArg(1)->getType()->isIntegralOrEnumerationType());
+
+ APSInt RHS = popToAPSInt(
+ S.Stk, *S.getContext().classify(Call->getArg(1)->getType()));
+ const Pointer &LHS = S.Stk.pop<Pointer>();
+ const Pointer &Dst = S.Stk.peek<Pointer>();
+
+ for (unsigned I = 0; I != NumElems; ++I) {
+ APSInt Elem1;
+ INT_TYPE_SWITCH_NO_BOOL(ElemT, {
+ Elem1 = LHS.elem<T>(I).toAPSInt();
+ });
+
+ APSInt Result =
+ APSInt(Fn(Elem1, RHS),
+ Call->getType()->isUnsignedIntegerOrEnumerationType());
----------------
RKSimon wrote:
OK - @Arghnews is going to handle this part in #155542 - and then this patch will become a rotate constexpr patch afterward
https://github.com/llvm/llvm-project/pull/156017
More information about the cfe-commits
mailing list