[llvm] 945ed22 - [X86] Move the implicit enabling of sse2 for 64-bit mode from X86Subtarget::initSubtargetFeatures to X86_MC::ParseX86Triple.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 11:18:57 PDT 2020


Author: Craig Topper
Date: 2020-07-24T11:14:20-07:00
New Revision: 945ed22f3397f52469618cd8a94207665f25bebd

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

LOG: [X86] Move the implicit enabling of sse2 for 64-bit mode from X86Subtarget::initSubtargetFeatures to X86_MC::ParseX86Triple.

ParseX86Triple already checks for 64-bit mode and produces a
static string. We can just add +sse2 to the end of that static
string. This avoids a potential reallocation when appending it
to the std::string at runtime.

This is a slight change to the behavior of tools that only use
MC layer which weren't implicitly enabling sse2 before, but will
now. I don't think we check for sse2 explicitly in any MC layer
components so this shouldn't matter in practice. And if it did
matter the new behavior is more correct.

Added: 
    

Modified: 
    llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
    llvm/lib/Target/X86/X86Subtarget.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 8a478354cb16..8679bafa088e 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -44,8 +44,10 @@ using namespace llvm;
 
 std::string X86_MC::ParseX86Triple(const Triple &TT) {
   std::string FS;
-  if (TT.getArch() == Triple::x86_64)
-    FS = "+64bit-mode,-32bit-mode,-16bit-mode";
+  // SSE2 should default to enabled in 64-bit mode, but can be turned off
+  // explicitly.
+  if (TT.isArch64Bit())
+    FS = "+64bit-mode,-32bit-mode,-16bit-mode,+sse2";
   else if (TT.getEnvironment() != Triple::CODE16)
     FS = "-64bit-mode,+32bit-mode,-16bit-mode";
   else

diff  --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index 51665255ec06..07e913e13911 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -234,11 +234,6 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
   std::string FullFS = X86_MC::ParseX86Triple(TargetTriple);
   assert(!FullFS.empty() && "Failed to parse X86 triple");
 
-  // SSE2 should default to enabled in 64-bit mode, but can be turned off
-  // explicitly.
-  if (TargetTriple.isArch64Bit())
-    FullFS += ",+sse2";
-
   if (!FS.empty())
     FullFS = (Twine(FullFS) + "," + FS).str();
 


        


More information about the llvm-commits mailing list