Skip to content

Commit 33ee854

Browse files
committed
Resolve ambiguity in LLVM instruction order
1 parent 24b7e86 commit 33ee854

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,15 +4313,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43134313
}
43144314

43154315
// For sh.* compiler intrinsics:
4316-
// llvm.x86.avx512fp16.mask.{add/sub/mul/div/max/min}.sh.round
4317-
// (<8 x half>, <8 x half>, <8 x half>, i8, i32)
4318-
// A B WriteThru Mask RoundingMode
4319-
//
4320-
// if (Mask[0])
4321-
// DstShadow[0] = AShadow[0] | BShadow[0]
4322-
// else
4323-
// DstShadow[0] = WriteThruShadow[0]
4316+
// llvm.x86.avx512fp16.mask.{add/sub/mul/div/max/min}.sh.round
4317+
// (<8 x half>, <8 x half>, <8 x half>, i8, i32)
4318+
// A B WriteThru Mask RoundingMode
43244319
//
4320+
// DstShadow[0] = Mask[0] ? (AShadow[0] | BShadow[0]) : WriteThruShadow[0]
43254321
// DstShadow[1..7] = AShadow[1..7]
43264322
void visitGenericScalarHalfwordInst(IntrinsicInst &I) {
43274323
IRBuilder<> IRB(&I);
@@ -4348,21 +4344,25 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43484344

43494345
Mask = IRB.CreateBitCast(
43504346
Mask, FixedVectorType::get(IRB.getInt1Ty(), NumElements));
4347+
Value *MaskLower =
4348+
IRB.CreateExtractElement(Mask, ConstantInt::get(IRB.getInt32Ty(), 0));
43514349

43524350
Value *AShadow = getShadow(A);
4351+
Value *AShadowLower = IRB.CreateExtractElement(
4352+
AShadow, ConstantInt::get(IRB.getInt32Ty(), 0));
4353+
43534354
Value *BShadow = getShadow(B);
4354-
Value *ABLowerShadow =
4355-
IRB.CreateOr(IRB.CreateExtractElement(
4356-
AShadow, ConstantInt::get(IRB.getInt32Ty(), 0)),
4357-
IRB.CreateExtractElement(
4358-
BShadow, ConstantInt::get(IRB.getInt32Ty(), 0)));
4355+
Value *BShadowLower = IRB.CreateExtractElement(
4356+
BShadow, ConstantInt::get(IRB.getInt32Ty(), 0));
4357+
4358+
Value *ABLowerShadow = IRB.CreateOr(AShadowLower, BShadowLower);
4359+
43594360
Value *WriteThroughShadow = getShadow(WriteThrough);
43604361
Value *WriteThroughLowerShadow = IRB.CreateExtractElement(
43614362
WriteThroughShadow, ConstantInt::get(IRB.getInt32Ty(), 0));
43624363

4363-
Value *DstLowerShadow = IRB.CreateSelect(
4364-
IRB.CreateExtractElement(Mask, ConstantInt::get(IRB.getInt32Ty(), 0)),
4365-
ABLowerShadow, WriteThroughLowerShadow);
4364+
Value *DstLowerShadow =
4365+
IRB.CreateSelect(MaskLower, ABLowerShadow, WriteThroughLowerShadow);
43664366
Value *DstShadow = IRB.CreateInsertElement(
43674367
AShadow, DstLowerShadow, ConstantInt::get(IRB.getInt32Ty(), 0),
43684368
"_msprop");

0 commit comments

Comments
 (0)