[PATCH] Refactor: Simplify boolean conditional return statements in llvm/lib/Analysis

Craig Topper craig.topper at gmail.com
Sun May 24 23:53:07 PDT 2015


================
Comment at: lib/Analysis/CostModel.cpp:155
@@ -154,6 +154,3 @@
   SmallVector<int, 16> ActualMask = SI->getShuffleMask();
-  if (Mask != ActualMask)
-    return false;
-
-  return true;
+  return !(Mask != ActualMask);
 }
----------------
Just use == here

================
Comment at: lib/Analysis/LoopAccessAnalysis.cpp:149
@@ -148,6 +148,3 @@
   // In this case we can't omit the check.
-  if (PtrPartition && (*PtrPartition)[I] != -1 &&
-      (*PtrPartition)[I] == (*PtrPartition)[J])
-    return false;
-
-  return true;
+  return !(PtrPartition && (*PtrPartition)[I] != -1 &&
+      (*PtrPartition)[I] == (*PtrPartition)[J]);
----------------
Maybe push the negate through and use ORs

================
Comment at: lib/Analysis/TargetLibraryInfo.cpp:45
@@ -44,6 +44,3 @@
 
-  if (T.isiOS() && T.isOSVersionLT(7, 0))
-    return false;
-
-  return true;
+  return !(T.isiOS() && T.isOSVersionLT(7, 0));
 }
----------------
Push the ! through and use an OR

http://reviews.llvm.org/D9967

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list