[llvm] r237343 - [TableGen] Remove an unnecessary outer 'if' around 3 separate inner ifs. No functional change intended.

Craig Topper craig.topper at gmail.com
Wed May 13 22:54:02 PDT 2015


Author: ctopper
Date: Thu May 14 00:54:02 2015
New Revision: 237343

URL: http://llvm.org/viewvc/llvm-project?rev=237343&view=rev
Log:
[TableGen] Remove an unnecessary outer 'if' around 3 separate inner ifs. No functional change intended.

The outer if had 3 separate conditions ORed together and then the inner ifs detected which of the three conditions it was by using only a portion of the specific condition. Just put the whole condition in each inner if and remove the outer if.

Modified:
    llvm/trunk/lib/TableGen/Record.cpp

Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=237343&r1=237342&r2=237343&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Thu May 14 00:54:02 2015
@@ -1096,35 +1096,31 @@ Init *TernOpInit::Fold(Record *CurRec, M
     VarInit *RHSv = dyn_cast<VarInit>(RHS);
     StringInit *RHSs = dyn_cast<StringInit>(RHS);
 
-    if ((LHSd && MHSd && RHSd) ||
-        (LHSv && MHSv && RHSv) ||
-        (LHSs && MHSs && RHSs)) {
-      if (RHSd) {
-        Record *Val = RHSd->getDef();
-        if (LHSd->getAsString() == RHSd->getAsString())
-          Val = MHSd->getDef();
-        return DefInit::get(Val);
-      }
-      if (RHSv) {
-        std::string Val = RHSv->getName();
-        if (LHSv->getAsString() == RHSv->getAsString())
-          Val = MHSv->getName();
-        return VarInit::get(Val, getType());
-      }
-      if (RHSs) {
-        std::string Val = RHSs->getValue();
+    if (LHSd && MHSd && RHSd) {
+      Record *Val = RHSd->getDef();
+      if (LHSd->getAsString() == RHSd->getAsString())
+        Val = MHSd->getDef();
+      return DefInit::get(Val);
+    }
+    if (LHSv && MHSv && RHSv) {
+      std::string Val = RHSv->getName();
+      if (LHSv->getAsString() == RHSv->getAsString())
+        Val = MHSv->getName();
+      return VarInit::get(Val, getType());
+    }
+    if (LHSs && MHSs && RHSs) {
+      std::string Val = RHSs->getValue();
 
-        std::string::size_type found;
-        std::string::size_type idx = 0;
-        do {
-          found = Val.find(LHSs->getValue(), idx);
-          if (found != std::string::npos)
-            Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
-          idx = found +  MHSs->getValue().size();
-        } while (found != std::string::npos);
+      std::string::size_type found;
+      std::string::size_type idx = 0;
+      do {
+        found = Val.find(LHSs->getValue(), idx);
+        if (found != std::string::npos)
+          Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
+        idx = found +  MHSs->getValue().size();
+      } while (found != std::string::npos);
 
-        return StringInit::get(Val);
-      }
+      return StringInit::get(Val);
     }
     break;
   }





More information about the llvm-commits mailing list