@@ -2989,17 +2989,22 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
29892989
29902990 // / Handle (SIMD arithmetic)-like intrinsics.
29912991 // /
2992- // / Instrument intrinsics with any number of arguments of the same type,
2993- // / equal to the return type. The type should be simple (no aggregates or
2994- // / pointers; vectors are fine).
2992+ // / Instrument intrinsics with any number of arguments of the same type [*],
2993+ // / equal to the return type, plus a specified number of trailing flags of
2994+ // / any type.
2995+ // /
2996+ // / [*} The type should be simple (no aggregates or pointers; vectors are
2997+ // / fine).
2998+ // /
29952999 // / Caller guarantees that this intrinsic does not access memory.
2996- bool maybeHandleSimpleNomemIntrinsic (IntrinsicInst &I) {
3000+ bool maybeHandleSimpleNomemIntrinsic (IntrinsicInst &I, unsigned int trailingFlags ) {
29973001 Type *RetTy = I.getType ();
29983002 if (!(RetTy->isIntOrIntVectorTy () || RetTy->isFPOrFPVectorTy ()))
29993003 return false ;
30003004
30013005 unsigned NumArgOperands = I.arg_size ();
3002- for (unsigned i = 0 ; i < NumArgOperands; ++i) {
3006+ assert (NumArgOperands >= trailingFlags);
3007+ for (unsigned i = 0 ; i < NumArgOperands - trailingFlags; ++i) {
30033008 Type *Ty = I.getArgOperand (i)->getType ();
30043009 if (Ty != RetTy)
30053010 return false ;
@@ -3043,7 +3048,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
30433048 }
30443049
30453050 if (I.doesNotAccessMemory ())
3046- if (maybeHandleSimpleNomemIntrinsic (I))
3051+ if (maybeHandleSimpleNomemIntrinsic (I, /* trailingFlags */ 0 ))
30473052 return true ;
30483053
30493054 // FIXME: detect and handle SSE maskstore/maskload?
@@ -4615,6 +4620,18 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
46154620 case Intrinsic::x86_avx2_maskload_d_256:
46164621 case Intrinsic::x86_avx2_maskload_q_256: {
46174622 handleAVXMaskedLoad (I);
4623+
4624+ // Packed
4625+ case Intrinsic::x86_avx512_min_ps_512:
4626+ case Intrinsic::x86_avx512_min_pd_512:
4627+ case Intrinsic::x86_avx512_max_ps_512:
4628+ case Intrinsic::x86_avx512_max_pd_512: {
4629+ // These AVX512 variants contain the rounding mode as a trailing flag.
4630+ // Earlier variants do not have a trailing flag and are already handled
4631+ // by maybeHandleSimpleNomemIntrinsic(I, 0) via handleUnknownIntrinsic.
4632+ bool success = maybeHandleSimpleNomemIntrinsic (I, /* trailingFlags */ 1 );
4633+ (void )success;
4634+ assert (success);
46184635 break ;
46194636 }
46204637
0 commit comments