[llvm] 626348d - [X86][mem-fold] Simplify code by using StringRef::drop_back, NFCI

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 08:40:55 PDT 2023


Author: Shengchen Kan
Date: 2023-04-05T23:40:28+08:00
New Revision: 626348dfc3ed5fef84f9e804f07e5932a411a53d

URL: https://github.com/llvm/llvm-project/commit/626348dfc3ed5fef84f9e804f07e5932a411a53d
DIFF: https://github.com/llvm/llvm-project/commit/626348dfc3ed5fef84f9e804f07e5932a411a53d.diff

LOG:  [X86][mem-fold] Simplify code by using StringRef::drop_back, NFCI

Added: 
    

Modified: 
    llvm/utils/TableGen/X86FoldTablesEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
index db5a31f7f3a6..d5338564eaf6 100644
--- a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -407,15 +407,14 @@ void X86FoldTablesEmitter::addEntryWithFlags(FoldTable &Table,
     Result.CannotUnfold = true;
 
   // Check no-kz version's isMoveReg
+  StringRef RegInstName = RegRec->getName();
   Record *BaseDef = nullptr;
-  if (RegRec->getName().ends_with("rkz") &&
-      (BaseDef = Records.getDef(
-           RegRec->getName().substr(0, RegRec->getName().size() - 2)))) {
+  if (RegInstName.endswith("rkz") &&
+      (BaseDef = Records.getDef(RegInstName.drop_back(2)))) {
     Result.CannotUnfold =
         Target.getInstruction(BaseDef).isMoveReg ? true : Result.CannotUnfold;
-  } else if (RegRec->getName().ends_with("rk") &&
-             (BaseDef = Records.getDef(
-                  RegRec->getName().substr(0, RegRec->getName().size() - 1)))) {
+  } else if (RegInstName.endswith("rk") &&
+             (BaseDef = Records.getDef(RegInstName.drop_back(1)))) {
     Result.CannotUnfold =
         Target.getInstruction(BaseDef).isMoveReg ? true : Result.CannotUnfold;
   } else if (RegInstr->isMoveReg && Result.IsStore)


        


More information about the llvm-commits mailing list