Skip to content

Commit 3513886

Browse files
authored
[msan] Generalize handleVectorReduceIntrinsic to support Arm NEON add reduction to scalar (#125288)
This generalizes handleVectorReduceIntrinsic to allow intrinsics where the return type is not the same as the fields. This patch then applies the generalized handleVectorReduceIntrinsic to support the following Arm NEON add reduction to scalar intrinsics: llvm.aarch64.neon.{faddv, saddv, uaddv}. Updates the tests from #125271
1 parent 6f35a9e commit 3513886

File tree

2 files changed

+117
-283
lines changed

2 files changed

+117
-283
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3493,11 +3493,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
34933493

34943494
// Instrument generic vector reduction intrinsics
34953495
// by ORing together all their fields.
3496+
//
3497+
// The return type does not need to be the same type as the fields
3498+
// e.g., declare i32 @llvm.aarch64.neon.uaddv.i32.v16i8(<16 x i8>)
34963499
void handleVectorReduceIntrinsic(IntrinsicInst &I) {
34973500
IRBuilder<> IRB(&I);
34983501
Value *S = IRB.CreateOrReduce(getShadow(&I, 0));
3502+
S = CreateShadowCast(IRB, S, getShadowTy(&I));
34993503
setShadow(&I, S);
3500-
setOrigin(&I, getOrigin(&I, 0));
3504+
setOriginForNaryOp(I);
35013505
}
35023506

35033507
// Instrument vector.reduce.or intrinsic.
@@ -4346,6 +4350,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43464350
case Intrinsic::vector_reduce_add:
43474351
case Intrinsic::vector_reduce_xor:
43484352
case Intrinsic::vector_reduce_mul:
4353+
// Add reduction to scalar
4354+
case Intrinsic::aarch64_neon_faddv:
4355+
case Intrinsic::aarch64_neon_saddv:
4356+
case Intrinsic::aarch64_neon_uaddv:
43494357
handleVectorReduceIntrinsic(I);
43504358
break;
43514359
case Intrinsic::x86_sse_stmxcsr:

0 commit comments

Comments
 (0)