[llvm] r273583 - [TableGen] Use StringRef::compare instead of != and <. NFC.

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 10:09:49 PDT 2016


Author: ab
Date: Thu Jun 23 12:09:49 2016
New Revision: 273583

URL: http://llvm.org/viewvc/llvm-project?rev=273583&view=rev
Log:
[TableGen] Use StringRef::compare instead of != and <. NFC.

The previous code would always do 1 or 2 prefix compares;
explicitly only do one.

This speeds up debug -gen-asm-matcher by ~10% (e.g. X86: 40s -> 35s).

Modified:
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=273583&r1=273582&r2=273583&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Thu Jun 23 12:09:49 2016
@@ -579,8 +579,8 @@ struct MatchableInfo {
   /// operator< - Compare two matchables.
   bool operator<(const MatchableInfo &RHS) const {
     // The primary comparator is the instruction mnemonic.
-    if (Mnemonic != RHS.Mnemonic)
-      return Mnemonic < RHS.Mnemonic;
+    if (int Cmp = Mnemonic.compare(RHS.Mnemonic))
+      return Cmp == -1;
 
     if (AsmOperands.size() != RHS.AsmOperands.size())
       return AsmOperands.size() < RHS.AsmOperands.size();




More information about the llvm-commits mailing list