Skip to content

Commit b598d4f

Browse files
committed
[msan] Generalize handleVectorReduceIntrinsic to support Arm NEON add reduction to scalar
This generalizes handleVectorReduceIntrinsic to allow intrinsics where the return type is not the same as the fields. This is then used to support the Arm NEON add reduction to scalar intrinsics (llvm.aarch64.neon.faddv, llvm.aarch64.neon.saddv, llvm.aarch64.neon.uaddv). Updates the tests from llvm#125271
1 parent b25fe9c commit b598d4f

File tree

2 files changed

+117
-278
lines changed

2 files changed

+117
-278
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.
@@ -4342,6 +4346,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43424346
case Intrinsic::vector_reduce_add:
43434347
case Intrinsic::vector_reduce_xor:
43444348
case Intrinsic::vector_reduce_mul:
4349+
// Add reduction to scalar
4350+
case Intrinsic::aarch64_neon_faddv:
4351+
case Intrinsic::aarch64_neon_saddv:
4352+
case Intrinsic::aarch64_neon_uaddv:
43454353
handleVectorReduceIntrinsic(I);
43464354
break;
43474355
case Intrinsic::x86_sse_stmxcsr:

0 commit comments

Comments
 (0)