[llvm] r355298 - [SubtargetFeatuers] Simplify the code used to imply features from CPU name.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 3 18:02:23 PST 2019
Author: ctopper
Date: Sun Mar 3 18:02:22 2019
New Revision: 355298
URL: http://llvm.org/viewvc/llvm-project?rev=355298&view=rev
Log:
[SubtargetFeatuers] Simplify the code used to imply features from CPU name.
If we make SetImpliedBits OR features outside of its loop, we can reuse it for the first round of implying features for CPUs.
Modified:
llvm/trunk/lib/MC/SubtargetFeature.cpp
Modified: llvm/trunk/lib/MC/SubtargetFeature.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/SubtargetFeature.cpp?rev=355298&r1=355297&r2=355298&view=diff
==============================================================================
--- llvm/trunk/lib/MC/SubtargetFeature.cpp (original)
+++ llvm/trunk/lib/MC/SubtargetFeature.cpp Sun Mar 3 18:02:22 2019
@@ -124,12 +124,12 @@ std::string SubtargetFeatures::getString
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(String
// 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";
More information about the llvm-commits
mailing list