Skip to content

Commit afea3aa

Browse files
thurstondIcohedron
authored andcommitted
[msan] Handle Intrinsic::vector_reduce_f{add,mul} (llvm#125615)
This adds handleVectorReduceWithStarterIntrinsic() (similar to handleVectorReduceIntrinsic but for intrinsics with an additional starting parameter) and uses it to handle Intrinsic::vector_reduce_f{add,mul}. Updates the tests from llvm#125597
1 parent 1ec9a41 commit afea3aa

File tree

3 files changed

+117
-302
lines changed

3 files changed

+117
-302
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,6 +3504,19 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
35043504
setOriginForNaryOp(I);
35053505
}
35063506

3507+
// Similar to handleVectorReduceIntrinsic but with an initial starting value.
3508+
// e.g., call float @llvm.vector.reduce.fadd.f32.v2f32(float %a0, <2 x float>
3509+
// %a1)
3510+
// shadow = shadow[a0] | shadow[a1.0] | shadow[a1.1]
3511+
void handleVectorReduceWithStarterIntrinsic(IntrinsicInst &I) {
3512+
IRBuilder<> IRB(&I);
3513+
Value *Shadow0 = getShadow(&I, 0);
3514+
Value *Shadow1 = IRB.CreateOrReduce(getShadow(&I, 1));
3515+
Value *S = IRB.CreateOr(Shadow0, Shadow1);
3516+
setShadow(&I, S);
3517+
setOriginForNaryOp(I);
3518+
}
3519+
35073520
// Instrument vector.reduce.or intrinsic.
35083521
// Valid (non-poisoned) set bits in the operand pull low the
35093522
// corresponding shadow bits.
@@ -4356,6 +4369,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43564369
case Intrinsic::aarch64_neon_uaddv:
43574370
handleVectorReduceIntrinsic(I);
43584371
break;
4372+
case Intrinsic::vector_reduce_fadd:
4373+
case Intrinsic::vector_reduce_fmul:
4374+
handleVectorReduceWithStarterIntrinsic(I);
4375+
break;
4376+
43594377
case Intrinsic::x86_sse_stmxcsr:
43604378
handleStmxcsr(I);
43614379
break;

0 commit comments

Comments
 (0)