[llvm] b2f7ce9 - [NFC] Simpler and faster key computation for getSubtargetImpl memoization

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 22 02:03:04 PDT 2021


Author: serge-sans-paille
Date: 2021-03-22T10:02:51+01:00
New Revision: b2f7ce91a644e3185eb1beb796b5cf4410378c70

URL: https://github.com/llvm/llvm-project/commit/b2f7ce91a644e3185eb1beb796b5cf4410378c70
DIFF: https://github.com/llvm/llvm-project/commit/b2f7ce91a644e3185eb1beb796b5cf4410378c70.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86TargetMachine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index 0f19accb8348..9deae9d0e306 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -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.


        


More information about the llvm-commits mailing list