Skip to content

Commit 05d04f0

Browse files
authored
[RISCV] Make RISCVISAInfo::updateMaxELen extension checking more robust. Add inference from V extension. (#90650)
We weren't fully checking that we parsed Zve*x/f/d correctly. This could break if new extension is added that starts with Zve. We were assuming the Zve64d is present whenever V is so we only inferred from Zve*. It's more correct to infer ELEN from V itself too.
1 parent 70ada5b commit 05d04f0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,19 +929,28 @@ void RISCVISAInfo::updateMinVLen() {
929929
}
930930

931931
void RISCVISAInfo::updateMaxELen() {
932+
assert(MaxELenFp == 0 && MaxELen == 0);
933+
if (Exts.count("v")) {
934+
MaxELenFp = std::max(MaxELenFp, 64u);
935+
MaxELen = std::max(MaxELen, 64u);
936+
}
937+
932938
// handles EEW restriction by sub-extension zve
933939
for (auto const &Ext : Exts) {
934940
StringRef ExtName = Ext.first;
935941
bool IsZveExt = ExtName.consume_front("zve");
936942
if (IsZveExt) {
937943
if (ExtName.back() == 'f')
938944
MaxELenFp = std::max(MaxELenFp, 32u);
939-
if (ExtName.back() == 'd')
945+
else if (ExtName.back() == 'd')
940946
MaxELenFp = std::max(MaxELenFp, 64u);
947+
else if (ExtName.back() != 'x')
948+
continue;
949+
941950
ExtName = ExtName.drop_back();
942951
unsigned ZveELen;
943-
ExtName.getAsInteger(10, ZveELen);
944-
MaxELen = std::max(MaxELen, ZveELen);
952+
if (!ExtName.getAsInteger(10, ZveELen))
953+
MaxELen = std::max(MaxELen, ZveELen);
945954
}
946955
}
947956
}

0 commit comments

Comments
 (0)