[llvm] ba852e1 - [X86] Don't call hasFnAttribute and getFnAttribute for 'prefer-vector-width' and 'min-legal-vector-width' in getSubtargetImpl
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 10:41:01 PDT 2020
Author: Craig Topper
Date: 2020-08-27T10:40:20-07:00
New Revision: ba852e1e19ab8605ed199ea125e11ed80ae15386
URL: https://github.com/llvm/llvm-project/commit/ba852e1e19ab8605ed199ea125e11ed80ae15386
DIFF: https://github.com/llvm/llvm-project/commit/ba852e1e19ab8605ed199ea125e11ed80ae15386.diff
LOG: [X86] Don't call hasFnAttribute and getFnAttribute for 'prefer-vector-width' and 'min-legal-vector-width' in getSubtargetImpl
We only need to call getFnAttribute and then check if the Attribute
is None or not.
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 2173b2633a7c..4c253aab6f22 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -254,8 +254,9 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
// Extract prefer-vector-width attribute.
unsigned PreferVectorWidthOverride = 0;
- if (F.hasFnAttribute("prefer-vector-width")) {
- StringRef Val = F.getFnAttribute("prefer-vector-width").getValueAsString();
+ Attribute PreferVecWidthAttr = F.getFnAttribute("prefer-vector-width");
+ if (!PreferVecWidthAttr.hasAttribute(Attribute::None)) {
+ StringRef Val = PreferVecWidthAttr.getValueAsString();
unsigned Width;
if (!Val.getAsInteger(0, Width)) {
Key += "prefer-vector-width=";
@@ -266,9 +267,9 @@ X86TargetMachine::getSubtargetImpl(const Function &F) const {
// Extract min-legal-vector-width attribute.
unsigned RequiredVectorWidth = UINT32_MAX;
- if (F.hasFnAttribute("min-legal-vector-width")) {
- StringRef Val =
- F.getFnAttribute("min-legal-vector-width").getValueAsString();
+ Attribute MinLegalVecWidthAttr = F.getFnAttribute("min-legal-vector-width");
+ if (!MinLegalVecWidthAttr.hasAttribute(Attribute::None)) {
+ StringRef Val = MinLegalVecWidthAttr.getValueAsString();
unsigned Width;
if (!Val.getAsInteger(0, Width)) {
Key += "min-legal-vector-width=";
More information about the llvm-commits
mailing list