[llvm] [WebAssembly] Constant fold wasm.dot (PR #149619)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 09:13:30 PDT 2025
================
@@ -3826,6 +3827,37 @@ 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());
+ SmallVector<APInt, 8> MulVector;
----------------
lukel97 wrote:
Nit, if we don't need the arbitrary precisioness of APInt or the dynamicness of a vector, we can just use a plain old int32_t array:
```suggestion
int32_t MulVector[8];
```
And then you can use `ConstantInt::getSExtValue` to get the values out. It should be a little bit faster than using an APInt.
https://github.com/llvm/llvm-project/pull/149619
More information about the llvm-commits
mailing list