]> granicus.if.org Git - llvm/commitdiff
[SubtargetFeatuers] Simplify the code used to imply features from CPU name.
authorCraig Topper <craig.topper@intel.com>
Mon, 4 Mar 2019 02:02:22 +0000 (02:02 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 4 Mar 2019 02:02:22 +0000 (02:02 +0000)
If we make SetImpliedBits OR features outside of its loop, we can reuse it for the first round of implying features for CPUs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355298 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/SubtargetFeature.cpp

index c34c6ff900744689f269d45d791fb019c5507044..84c743c5e33763fc2c148d1e650de78531691f4b 100644 (file)
@@ -124,12 +124,12 @@ std::string SubtargetFeatures::getString() const {
 static
 void SetImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies,
                     ArrayRef<SubtargetFeatureKV> FeatureTable) {
-  for (const SubtargetFeatureKV &FE : FeatureTable) {
-    if (Implies.test(FE.Value)) {
-      Bits.set(FE.Value);
+  // OR the Implies bits in outside the loop. This allows the Implies for CPUs
+  // which might imply features not in FeatureTable to use this.
+  Bits |= Implies;
+  for (const SubtargetFeatureKV &FE : FeatureTable)
+    if (Implies.test(FE.Value))
       SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable);
-    }
-  }
 }
 
 /// For each feature that (transitively) implies this feature, clear it.
@@ -219,15 +219,8 @@ SubtargetFeatures::getFeatureBits(StringRef CPU,
 
     // If there is a match
     if (CPUEntry) {
-      // Set base feature bits
-      FeatureBitset CPUImplies = CPUEntry->Implies.getAsBitset();
-      Bits = CPUImplies;
-
-      // Set the feature implied by this CPU feature, if any.
-      for (auto &FE : FeatureTable) {
-        if (CPUImplies.test(FE.Value))
-          SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable);
-      }
+      // Set the features implied by this CPU feature, if any.
+      SetImpliedBits(Bits, CPUEntry->Implies.getAsBitset(), FeatureTable);
     } else {
       errs() << "'" << CPU << "' is not a recognized processor for this target"
              << " (ignoring processor)\n";