[PATCH] D10001: Refactor: Simplify boolean conditional return statements in lib/Transforms/Util

Richard via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 24 13:53:34 PDT 2015


LegalizeAdulthood updated this revision to Diff 38329.
LegalizeAdulthood added a comment.

Update from latest.
Update from comments.
I do not have commit access.


http://reviews.llvm.org/D10001

Files:
  lib/Transforms/Utils/Local.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  lib/Transforms/Utils/SimplifyIndVar.cpp

Index: lib/Transforms/Utils/SimplifyIndVar.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyIndVar.cpp
+++ lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -297,10 +297,7 @@
     }
   }
 
-  if (eliminateIdentitySCEV(UseInst, IVOperand))
-    return true;
-
-  return false;
+  return eliminateIdentitySCEV(UseInst, IVOperand);
 }
 
 /// Eliminate any operation that SCEV can prove is an identity function.
@@ -504,10 +501,7 @@
 
   // Only consider affine recurrences.
   const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S);
-  if (AR && AR->getLoop() == L)
-    return true;
-
-  return false;
+  return AR && AR->getLoop() == L;
 }
 
 /// Iteratively perform simplification on a worklist of users
Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3660,11 +3660,8 @@
   // is unreachable.
   DefaultResult =
       DefaultResults.size() == 1 ? DefaultResults.begin()->second : nullptr;
-  if ((!DefaultResult &&
-        !isa<UnreachableInst>(DefaultDest->getFirstNonPHIOrDbg())))
-    return false;
-
-  return true;
+  return !(!DefaultResult &&
+        !isa<UnreachableInst>(DefaultDest->getFirstNonPHIOrDbg()));
 }
 
 // Helper function that checks if it is possible to transform a switch with only
Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -296,14 +296,10 @@
   // We don't want debug info removed by anything this general, unless
   // debug info is empty.
   if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) {
-    if (DDI->getAddress())
-      return false;
-    return true;
+    return DDI->getAddress() == nullptr;
   }
   if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
-    if (DVI->getValue())
-      return false;
-    return true;
+    return DVI->getValue() == nullptr;
   }
 
   if (!I->mayHaveSideEffects()) return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10001.38329.patch
Type: text/x-patch
Size: 2092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151024/262f0231/attachment.bin>


More information about the llvm-commits mailing list