[llvm] [WebAssembly] Reapply #149619 (PR #153070)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 13 23:10:52 PDT 2025
================
@@ -3826,6 +3827,30 @@ static Constant *ConstantFoldFixedVectorCall(
}
return ConstantVector::get(Result);
}
+ case Intrinsic::wasm_dot: {
+ unsigned NumElements =
+ cast<FixedVectorType>(Operands[0]->getType())->getNumElements();
+
+ assert(NumElements == 8 && Result.size() == 4 &&
+ "wasm dot takes i16x8 and produces i32x4");
+ assert(Ty->isIntegerTy());
+ int32_t MulVector[8];
+
+ for (unsigned I = 0; I < NumElements; ++I) {
+ ConstantInt *Elt0 =
+ cast<ConstantInt>(Operands[0]->getAggregateElement(I));
+ ConstantInt *Elt1 =
+ cast<ConstantInt>(Operands[1]->getAggregateElement(I));
+
+ MulVector[I] = Elt0->getSExtValue() * Elt1->getSExtValue();
+ }
+ for (unsigned I = 0; I < Result.size(); I++) {
+ int64_t IAdd = (int64_t)MulVector[I * 2] + MulVector[I * 2 + 1];
----------------
lukel97 wrote:
Just checking, this isn't allowing the wrap around right? It's promoting the multiplication from int32_t to int64_t? Might be good to specify that in the PR description
https://github.com/llvm/llvm-project/pull/153070
More information about the llvm-commits
mailing list