@@ -2989,17 +2989,22 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2989
2989
2990
2990
// / Handle (SIMD arithmetic)-like intrinsics.
2991
2991
// /
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
+ // /
2995
2999
// / Caller guarantees that this intrinsic does not access memory.
2996
- bool maybeHandleSimpleNomemIntrinsic (IntrinsicInst &I) {
3000
+ bool maybeHandleSimpleNomemIntrinsic (IntrinsicInst &I, unsigned int trailingFlags ) {
2997
3001
Type *RetTy = I.getType ();
2998
3002
if (!(RetTy->isIntOrIntVectorTy () || RetTy->isFPOrFPVectorTy ()))
2999
3003
return false ;
3000
3004
3001
3005
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) {
3003
3008
Type *Ty = I.getArgOperand (i)->getType ();
3004
3009
if (Ty != RetTy)
3005
3010
return false ;
@@ -3043,7 +3048,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
3043
3048
}
3044
3049
3045
3050
if (I.doesNotAccessMemory ())
3046
- if (maybeHandleSimpleNomemIntrinsic (I))
3051
+ if (maybeHandleSimpleNomemIntrinsic (I, /* trailingFlags */ 0 ))
3047
3052
return true ;
3048
3053
3049
3054
// FIXME: detect and handle SSE maskstore/maskload?
@@ -4684,6 +4689,18 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
4684
4689
case Intrinsic::x86_avx2_maskload_d_256:
4685
4690
case Intrinsic::x86_avx2_maskload_q_256: {
4686
4691
handleAVXMaskedLoad (I);
4692
+
4693
+ // Packed
4694
+ case Intrinsic::x86_avx512_min_ps_512:
4695
+ case Intrinsic::x86_avx512_min_pd_512:
4696
+ case Intrinsic::x86_avx512_max_ps_512:
4697
+ case Intrinsic::x86_avx512_max_pd_512: {
4698
+ // These AVX512 variants contain the rounding mode as a trailing flag.
4699
+ // Earlier variants do not have a trailing flag and are already handled
4700
+ // by maybeHandleSimpleNomemIntrinsic(I, 0) via handleUnknownIntrinsic.
4701
+ bool success = maybeHandleSimpleNomemIntrinsic (I, /* trailingFlags */ 1 );
4702
+ (void )success;
4703
+ assert (success);
4687
4704
break ;
4688
4705
}
4689
4706
0 commit comments