Skip to content

Commit b2f7ce9

Browse files
author
serge-sans-paille
committed
[NFC] Simpler and faster key computation for getSubtargetImpl memoization
There's no use in computing a large key that's only used for a memoization optimization.
1 parent c691b96 commit b2f7ce9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/lib/Target/X86/X86TargetMachine.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
248248
StringRef FS =
249249
FSAttr.isValid() ? FSAttr.getValueAsString() : (StringRef)TargetFS;
250250

251-
SmallString<512> Key;
251+
SmallString<64> Key;
252252
// The additions here are ordered so that the definitely short strings are
253253
// added first so we won't exceed the small size. We append the
254254
// much longer FS string at the end so that we only heap allocate at most
@@ -261,7 +261,7 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
261261
StringRef Val = PreferVecWidthAttr.getValueAsString();
262262
unsigned Width;
263263
if (!Val.getAsInteger(0, Width)) {
264-
Key += "prefer-vector-width=";
264+
Key += 'p';
265265
Key += Val;
266266
PreferVectorWidthOverride = Width;
267267
}
@@ -274,7 +274,7 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
274274
StringRef Val = MinLegalVecWidthAttr.getValueAsString();
275275
unsigned Width;
276276
if (!Val.getAsInteger(0, Width)) {
277-
Key += "min-legal-vector-width=";
277+
Key += 'm';
278278
Key += Val;
279279
RequiredVectorWidth = Width;
280280
}
@@ -284,7 +284,6 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
284284
Key += CPU;
285285

286286
// Add tune CPU to the Key.
287-
Key += "tune=";
288287
Key += TuneCPU;
289288

290289
// Keep track of the start of the feature portion of the string.

0 commit comments

Comments
 (0)