[PATCH] D106457: [Matrix] Fix miscompile for NT matmul if the transpose has other use
Adam Nemet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 21 09:57:52 PDT 2021
anemet created this revision.
anemet added a reviewer: fhahn.
Herald added subscribers: tschuett, hiraditya.
anemet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We should only add the fake lowering entry for the matrix remark if the
transpose is not lowered on its own. `MapVector::insert` is used to insert
the entry during proper lowering which does not overwrite the fake entry in
the map.
We actually had test coverage for this but the reference output code was
wrong; it was storing undef rather than the transposed column.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106457
Files:
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-right-transpose.ll
Index: llvm/test/Transforms/LowerMatrixIntrinsics/multiply-right-transpose.ll
===================================================================
--- llvm/test/Transforms/LowerMatrixIntrinsics/multiply-right-transpose.ll
+++ llvm/test/Transforms/LowerMatrixIntrinsics/multiply-right-transpose.ll
@@ -91,10 +91,10 @@
; CHECK-NEXT: [[TMP11:%.*]] = insertelement <3 x double> [[TMP9]], double [[TMP10]], i64 2
; CHECK-NEXT: [[TMP12:%.*]] = bitcast <6 x double>* [[P:%.*]] to double*
; CHECK-NEXT: [[VEC_CAST:%.*]] = bitcast double* [[TMP12]] to <3 x double>*
-; CHECK-NEXT: store <3 x double> undef, <3 x double>* [[VEC_CAST]], align 16
+; CHECK-NEXT: store <3 x double> [[TMP5]], <3 x double>* [[VEC_CAST]], align 16
; CHECK-NEXT: [[VEC_GEP:%.*]] = getelementptr double, double* [[TMP12]], i64 3
; CHECK-NEXT: [[VEC_CAST42:%.*]] = bitcast double* [[VEC_GEP]] to <3 x double>*
-; CHECK-NEXT: store <3 x double> undef, <3 x double>* [[VEC_CAST42]], align 8
+; CHECK-NEXT: store <3 x double> [[TMP11]], <3 x double>* [[VEC_CAST42]], align 8
; CHECK-NEXT: [[SPLIT:%.*]] = shufflevector <6 x double> [[A:%.*]], <6 x double> poison, <2 x i32> <i32 0, i32 1>
; CHECK-NEXT: [[SPLIT1:%.*]] = shufflevector <6 x double> [[A]], <6 x double> poison, <2 x i32> <i32 2, i32 3>
; CHECK-NEXT: [[SPLIT2:%.*]] = shufflevector <6 x double> [[A]], <6 x double> poison, <2 x i32> <i32 4, i32 5>
Index: llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -1540,11 +1540,11 @@
if (Transpose->hasOneUse()) {
FusedInsts.insert(cast<Instruction>(Transpose));
ToRemove.push_back(cast<Instruction>(Transpose));
+ // TODO: add a fake entry for the folded instruction so that this is
+ // included in the expression in the remark.
+ Inst2ColumnMatrix[Transpose] = MatrixTy(M, C, EltType);
}
finalizeLowering(MatMul, Result, Builder);
- // TODO: add a fake entry for the folded instruction so that this is
- // included in the expression in the remark.
- Inst2ColumnMatrix[Transpose] = MatrixTy(M, C, EltType);
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106457.360500.patch
Type: text/x-patch
Size: 2307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210721/800fd57b/attachment.bin>
More information about the llvm-commits
mailing list