[llvm] [msan] Add handler for llvm.x86.avx512.mask.cvtps2dq.512 (PR #147377)
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 13:01:26 PDT 2025
================
@@ -4342,6 +4342,61 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
setOriginForNaryOp(I);
}
+ // e.g., call <16 x i32> @llvm.x86.avx512.mask.cvtps2dq.512
+ // (<16 x float> a, <16 x i32> writethru, i16 mask,
+ // i32 rounding)
+ //
+ // dst[i] = mask[i] ? convert(a[i]) : writethru[i]
+ // dst_shadow[i] = mask[i] ? all_or_nothing(a_shadow[i]) : writethru_shadow[i]
+ // where all_or_nothing(x) is fully uninitialized if x has any
+ // uninitialized bits
+ void handleAVX512VectorConvertFPToInt(IntrinsicInst &I) {
+ IRBuilder<> IRB(&I);
+
+ assert(I.arg_size() == 4);
+ Value *A = I.getOperand(0);
+ Value *WriteThrough = I.getOperand(1);
+ Value *Mask = I.getOperand(2);
+ [[maybe_unused]] Value *RoundingMode = I.getOperand(3);
+
+ assert(isa<FixedVectorType>(A->getType()));
+ assert(A->getType()->isFPOrFPVectorTy());
+
+ assert(isa<FixedVectorType>(WriteThrough->getType()));
+ assert(WriteThrough->getType()->isIntOrIntVectorTy());
+
+ unsigned ANumElements =
+ cast<FixedVectorType>(A->getType())->getNumElements();
+ assert(ANumElements ==
+ cast<FixedVectorType>(WriteThrough->getType())->getNumElements());
+
+ assert(Mask->getType()->isIntegerTy());
+ assert(Mask->getType()->getScalarSizeInBits() == ANumElements);
+
+ assert(RoundingMode->getType()->isIntegerTy());
+
+ assert(I.getType() == WriteThrough->getType());
+
+ // Convert i16 mask to <16 x i1>
+ Mask = IRB.CreateBitCast(
+ Mask, FixedVectorType::get(IRB.getInt1Ty(), ANumElements));
+
+ Value *AShadow = getShadow(A);
+ /// For scalars:
+ /// Since they are converting from floating-point, the output is:
+ /// - fully uninitialized if *any* bit of the input is uninitialized
+ /// - fully ininitialized if all bits of the input are ininitialized
+ /// We apply the same principle on a per-field basis for vectors.
----------------
fmayer wrote:
per-element?
https://github.com/llvm/llvm-project/pull/147377
More information about the llvm-commits
mailing list