[TableGen] Remove an unnecessary outer 'if' around 3 separate inner ifs. No functiona...
authorCraig Topper <craig.topper@gmail.com>
Thu, 14 May 2015 05:54:02 +0000 (05:54 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 14 May 2015 05:54:02 +0000 (05:54 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237343 91177308-0d34-0410-b5e6-96231b3b80d8

lib/TableGen/Record.cpp

index a9229175b7a3b21309f0a4eef75c233ba7c15e78..7229b8c30a39197494f4d95f191f0735eef0d62c 100644 (file)
@@ -1096,35 +1096,31 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
     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();
-
-        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);
-      }
+    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);
+
+      return StringInit::get(Val);
     }
     break;
   }