[llvm] [Utils] Use StringRef::starts_with (NFC) (PR #138379)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 22:46:20 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/138379.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/IRNormalizer.cpp (+3-3) 


``````````diff
diff --git a/llvm/lib/Transforms/Utils/IRNormalizer.cpp b/llvm/lib/Transforms/Utils/IRNormalizer.cpp
index 75e775086493a..fd355ff9294cc 100644
--- a/llvm/lib/Transforms/Utils/IRNormalizer.cpp
+++ b/llvm/lib/Transforms/Utils/IRNormalizer.cpp
@@ -367,7 +367,7 @@ void IRNormalizer::foldInstructionName(Instruction *I) const {
   }
 
   // Don't fold if it is an output instruction or has no op prefix.
-  if (isOutput(I) || I->getName().substr(0, 2) != "op")
+  if (isOutput(I) || !I->getName().starts_with("op"))
     return;
 
   // Instruction operands.
@@ -375,8 +375,8 @@ void IRNormalizer::foldInstructionName(Instruction *I) const {
 
   for (auto &Op : I->operands()) {
     if (const auto *I = dyn_cast<Instruction>(Op)) {
-      bool HasNormalName = I->getName().substr(0, 2) == "op" ||
-                           I->getName().substr(0, 2) == "vl";
+      bool HasNormalName =
+          I->getName().starts_with("op") || I->getName().starts_with("vl");
 
       Operands.push_back(HasNormalName ? I->getName().substr(0, 7)
                                        : I->getName());

``````````

</details>


https://github.com/llvm/llvm-project/pull/138379


More information about the llvm-commits mailing list