[NFC] Simpler and faster key computation for getSubtargetImpl memoization
authorserge-sans-paille <sguelton@redhat.com>
Mon, 22 Mar 2021 08:52:39 +0000 (09:52 +0100)
committerserge-sans-paille <sguelton@redhat.com>
Mon, 22 Mar 2021 09:02:51 +0000 (10:02 +0100)
There's no use in computing a large key that's only used for a memoization
optimization.

llvm/lib/Target/X86/X86TargetMachine.cpp

index 0f19acc..9deae9d 100644 (file)
@@ -248,7 +248,7 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
   StringRef FS =
       FSAttr.isValid() ? FSAttr.getValueAsString() : (StringRef)TargetFS;
 
-  SmallString<512> Key;
+  SmallString<64> Key;
   // The additions here are ordered so that the definitely short strings are
   // added first so we won't exceed the small size. We append the
   // 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 {
     StringRef Val = PreferVecWidthAttr.getValueAsString();
     unsigned Width;
     if (!Val.getAsInteger(0, Width)) {
-      Key += "prefer-vector-width=";
+      Key += 'p';
       Key += Val;
       PreferVectorWidthOverride = Width;
     }
@@ -274,7 +274,7 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
     StringRef Val = MinLegalVecWidthAttr.getValueAsString();
     unsigned Width;
     if (!Val.getAsInteger(0, Width)) {
-      Key += "min-legal-vector-width=";
+      Key += 'm';
       Key += Val;
       RequiredVectorWidth = Width;
     }
@@ -284,7 +284,6 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
   Key += CPU;
 
   // Add tune CPU to the Key.
-  Key += "tune=";
   Key += TuneCPU;
 
   // Keep track of the start of the feature portion of the string.