Skip to content

Commit b00ad36

Browse files
authored
[RISCV] Use hasFeature instead of checkFeature in llvm-exegesis. NFC (#131401)
Until recently checkFeature was quite slow. #130936 I was curious where we use checkFeature and noticed these. I thought we could use hasFeature instead of going through strings.
1 parent eef5ea0 commit b00ad36

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,18 @@ template <class BaseT> class RISCVSnippetGenerator : public BaseT {
156156
// FIXME: We could have obtained these two constants from RISCVSubtarget
157157
// but in order to get that from TargetMachine, we need a Function.
158158
const MCSubtargetInfo &STI = State.getSubtargetInfo();
159-
ELEN = STI.checkFeatures("+zve64x") ? 64 : 32;
160-
161-
std::string ZvlQuery;
162-
for (unsigned Size = 32; Size <= 65536; Size *= 2) {
163-
ZvlQuery = "+zvl";
164-
raw_string_ostream SS(ZvlQuery);
165-
SS << Size << "b";
166-
if (STI.checkFeatures(SS.str()) && ZvlVLen < Size)
167-
ZvlVLen = Size;
159+
ELEN = STI.hasFeature(RISCV::FeatureStdExtZve64x) ? 64 : 32;
160+
161+
const unsigned ZvlFeatures[] = {
162+
RISCV::FeatureStdExtZvl32b, RISCV::FeatureStdExtZvl64b,
163+
RISCV::FeatureStdExtZvl128b, RISCV::FeatureStdExtZvl256b,
164+
RISCV::FeatureStdExtZvl512b, RISCV::FeatureStdExtZvl1024b,
165+
RISCV::FeatureStdExtZvl2048b, RISCV::FeatureStdExtZvl4096b,
166+
RISCV::FeatureStdExtZvl8192b, RISCV::FeatureStdExtZvl16384b,
167+
RISCV::FeatureStdExtZvl32768b, RISCV::FeatureStdExtZvl65536b};
168+
for (auto [Idx, Feature] : enumerate(ZvlFeatures)) {
169+
if (STI.hasFeature(Feature))
170+
ZvlVLen = std::max(ZvlVLen, 1u << (Idx + 5));
168171
}
169172
}
170173

0 commit comments

Comments
 (0)