[PATCH] D156223: [RISCV] Resolve a few bugs in RISCVVIntrinsicUtils.cpp
Brandon Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 25 03:37:16 PDT 2023
4vtomat created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD, MaskRay.
Herald added a project: clang.
This patch does a few things:
1. Add a new type called Undefined to ScalarTypeKind.
2. Make RVVType::applyModifier early return when encounter invalid ScalarType, otherwise it could be modified to "non-invalid" type in the following code.
3. When FixedLMULType::SmallerThan is applied, the lmul should be "<" than specified one, so lmuls which are ">=" should be marked as invalid.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156223
Files:
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Sema/SemaRISCVVectorLookup.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===================================================================
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -742,6 +742,10 @@
break;
}
+ // Early return if the current type modifier is already invalid.
+ if (ScalarType == Invalid)
+ return;
+
for (unsigned TypeModifierMaskShift = 0;
TypeModifierMaskShift <= static_cast<unsigned>(TypeModifier::MaxOffset);
++TypeModifierMaskShift) {
@@ -803,13 +807,13 @@
void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) {
switch (Type) {
case FixedLMULType::LargerThan:
- if (Log2LMUL < LMUL.Log2LMUL) {
+ if (Log2LMUL <= LMUL.Log2LMUL) {
ScalarType = ScalarTypeKind::Invalid;
return;
}
break;
case FixedLMULType::SmallerThan:
- if (Log2LMUL > LMUL.Log2LMUL) {
+ if (Log2LMUL >= LMUL.Log2LMUL) {
ScalarType = ScalarTypeKind::Invalid;
return;
}
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===================================================================
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -133,6 +133,7 @@
}
break;
case Invalid:
+ case Undefined:
llvm_unreachable("Unhandled type.");
}
if (Type->isVector()) {
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===================================================================
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -218,6 +218,7 @@
UnsignedInteger,
Float,
Invalid,
+ Undefined,
};
// Exponential LMUL
@@ -240,7 +241,7 @@
friend class RVVTypeCache;
BasicType BT;
- ScalarTypeKind ScalarType = Invalid;
+ ScalarTypeKind ScalarType = Undefined;
LMULType LMUL;
bool IsPointer = false;
// IsConstant indices are "int", but have the constant expression.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156223.543913.patch
Type: text/x-patch
Size: 1968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230725/fe7ef7d9/attachment.bin>
More information about the cfe-commits
mailing list