Skip to content

Commit 71a3ece

Browse files
committed
rever changes to CGExprScalar.cpp as the suggestion was a missunderstanding. fix up some typos
1 parent fef4b65 commit 71a3ece

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,26 +2977,27 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
29772977
return Builder.CreateExtractElement(Vec, Zero, "cast.vtrunc");
29782978
}
29792979
case CK_HLSLMatrixTruncation: {
2980-
assert((DestTy->isConstantMatrixType() || DestTy->isBuiltinType()) &&
2980+
assert((DestTy->isMatrixType() || DestTy->isBuiltinType()) &&
29812981
"Destination type must be a matrix or builtin type.");
29822982
Value *Mat = Visit(E);
2983-
unsigned NumCols = 1;
2984-
unsigned NumRows = 1;
2985-
SmallVector<int> Mask;
29862983
if (auto *MatTy = DestTy->getAs<ConstantMatrixType>()) {
2987-
NumCols = MatTy->getNumColumns();
2988-
NumRows = MatTy->getNumRows();
2989-
}
2990-
unsigned ColOffset = NumCols;
2991-
if (auto *SrcMatTy = E->getType()->getAs<ConstantMatrixType>())
2992-
ColOffset = SrcMatTy->getNumColumns();
2993-
for (unsigned R = 0; R < NumRows; R++) {
2994-
for (unsigned C = 0; C < NumCols; C++) {
2995-
unsigned I = R * ColOffset + C;
2996-
Mask.push_back(I);
2984+
SmallVector<int> Mask;
2985+
unsigned NumCols = MatTy->getNumColumns();
2986+
unsigned NumRows = MatTy->getNumRows();
2987+
unsigned ColOffset = NumCols;
2988+
if (auto *SrcMatTy = E->getType()->getAs<ConstantMatrixType>())
2989+
ColOffset = SrcMatTy->getNumColumns();
2990+
for (unsigned R = 0; R < NumRows; R++) {
2991+
for (unsigned C = 0; C < NumCols; C++) {
2992+
unsigned I = R * ColOffset + C;
2993+
Mask.push_back(I);
2994+
}
29972995
}
2996+
2997+
return Builder.CreateShuffleVector(Mat, Mask, "trunc");
29982998
}
2999-
return Builder.CreateShuffleVector(Mat, Mask, "trunc");
2999+
llvm::Value *Zero = llvm::Constant::getNullValue(CGF.SizeTy);
3000+
return Builder.CreateExtractElement(Mat, Zero, "cast.mtrunc");
30003001
}
30013002
case CK_HLSLElementwiseCast: {
30023003
RValue RV = CGF.EmitAnyExpr(E);

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12590,7 +12590,7 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
1259012590
Source = cast<VectorType>(Source)->getElementType().getTypePtr();
1259112591
Target = cast<VectorType>(Target)->getElementType().getTypePtr();
1259212592
}
12593-
if (auto VecTy = dyn_cast<VectorType>(Target))
12593+
if (const auto *VecTy = dyn_cast<VectorType>(Target))
1259412594
Target = VecTy->getElementType().getTypePtr();
1259512595

1259612596
if (isa<ConstantMatrixType>(Source)) {

clang/lib/Sema/SemaOverload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ static bool IsMatrixConversion(Sema &S, QualType FromType, QualType ToType,
21212121
auto *ToMatrixType = ToType->getAs<ConstantMatrixType>();
21222122
auto *FromMatrixType = FromType->getAs<ConstantMatrixType>();
21232123

2124-
// If both arguments are vectors, handle possible vector truncation and
2124+
// If both arguments are matrix, handle possible matrix truncation and
21252125
// element conversion.
21262126
if (ToMatrixType && FromMatrixType) {
21272127
unsigned FromCols = FromMatrixType->getNumColumns();

0 commit comments

Comments
 (0)