@@ -781,29 +781,21 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
781781 if (FPUKind == llvm::ARM::FK_FPV5_D16 || FPUKind == llvm::ARM::FK_FPV5_SP_D16)
782782 Features.push_back (" -mve.fp" );
783783
784- // If SIMD has been disabled and the selected FPU support NEON, then features
785- // that rely on NEON Instructions should also be disabled. Cases where NEON
786- // needs activating to support another feature is handled below with the
787- // crypto feature.
784+ // If SIMD has been disabled and the selected FPU supports NEON, then features
785+ // that rely on NEON instructions should also be disabled.
788786 bool HasSimd = false ;
789787 const auto ItSimd =
790788 llvm::find_if (llvm::reverse (Features),
791789 [](const StringRef F) { return F.contains (" neon" ); });
792- const bool FoundSimd = ItSimd != Features.rend ();
793790 const bool FPUSupportsNeon = (llvm::ARM::FPUNames[FPUKind].NeonSupport ==
794791 llvm::ARM::NeonSupportLevel::Neon) ||
795792 (llvm::ARM::FPUNames[FPUKind].NeonSupport ==
796793 llvm::ARM::NeonSupportLevel::Crypto);
797- if (FoundSimd)
798- HasSimd = ItSimd->take_front () == " +" ;
799- if (!HasSimd && FPUSupportsNeon) {
800- Features.push_back (" -sha2" );
801- Features.push_back (" -aes" );
802- Features.push_back (" -crypto" );
803- Features.push_back (" -dotprod" );
804- Features.push_back (" -bf16" );
805- Features.push_back (" -imm8" );
806- }
794+ if (ItSimd != Features.rend ())
795+ HasSimd = ItSimd->starts_with (" +" );
796+ if (!HasSimd && FPUSupportsNeon)
797+ for (auto &F : {" -sha2" , " -aes" , " -crypto" , " -dotprod" , " -bf16" , " -imm8" })
798+ Features.push_back (F);
807799
808800 // For Arch >= ARMv8.0 && A or R profile: crypto = sha2 + aes
809801 // Rather than replace within the feature vector, determine whether each
@@ -840,15 +832,15 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
840832 llvm::find_if (llvm::reverse (Features),
841833 [](const StringRef F) { return F.contains (" i8mm" ); });
842834 if (ItSHA2 != Features.rend ())
843- HasSHA2 = ItSHA2->take_front () == " +" ;
835+ HasSHA2 = ItSHA2->starts_with ( " +" ) ;
844836 if (ItAES != Features.rend ())
845- HasAES = ItAES->take_front () == " +" ;
837+ HasAES = ItAES->starts_with ( " +" ) ;
846838 if (ItBF16 != Features.rend ())
847- HasBF16 = ItBF16->take_front () == " +" ;
839+ HasBF16 = ItBF16->starts_with ( " +" ) ;
848840 if (ItDotprod != Features.rend ())
849- HasDotprod = ItDotprod->take_front () == " +" ;
841+ HasDotprod = ItDotprod->starts_with ( " +" ) ;
850842 if (ItI8MM != Features.rend ())
851- HasI8MM = ItI8MM->take_front () == " +" ;
843+ HasI8MM = ItI8MM->starts_with ( " +" ) ;
852844 if (ItCrypto != Features.rend ()) {
853845 if (HasSHA2 && HasAES)
854846 Features.push_back (" +crypto" );
0 commit comments