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

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


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

Update from latest
I do not have commit access.


http://reviews.llvm.org/D9974

Files:
  lib/IR/BasicBlock.cpp
  lib/IR/InlineAsm.cpp
  lib/IR/Instructions.cpp
  lib/IR/Verifier.cpp

Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -1517,12 +1517,9 @@
 
   unsigned LastSlot = Attrs.getNumSlots() - 1;
   unsigned LastIndex = Attrs.getSlotIndex(LastSlot);
-  if (LastIndex <= Params
-      || (LastIndex == AttributeSet::FunctionIndex
-          && (LastSlot == 0 || Attrs.getSlotIndex(LastSlot - 1) <= Params)))
-    return true;
-
-  return false;
+  return LastIndex <= Params ||
+         (LastIndex == AttributeSet::FunctionIndex &&
+          (LastSlot == 0 || Attrs.getSlotIndex(LastSlot - 1) <= Params));
 }
 
 /// \brief Verify that statepoint intrinsic is well formed.
Index: lib/IR/Instructions.cpp
===================================================================
--- lib/IR/Instructions.cpp
+++ lib/IR/Instructions.cpp
@@ -1693,9 +1693,7 @@
 
 
 bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
-  if (!Val->getType()->isVectorTy() || !Index->getType()->isIntegerTy())
-    return false;
-  return true;
+  return Val->getType()->isVectorTy() && Index->getType()->isIntegerTy();
 }
 
 
Index: lib/IR/InlineAsm.cpp
===================================================================
--- lib/IR/InlineAsm.cpp
+++ lib/IR/InlineAsm.cpp
@@ -288,8 +288,7 @@
     if (!STy || STy->getNumElements() != NumOutputs)
       return false;
     break;
-  }      
-  
-  if (Ty->getNumParams() != NumInputs) return false;
-  return true;
+  }
+
+  return Ty->getNumParams() == NumInputs;
 }
Index: lib/IR/BasicBlock.cpp
===================================================================
--- lib/IR/BasicBlock.cpp
+++ lib/IR/BasicBlock.cpp
@@ -340,9 +340,7 @@
   // This is perhaps a little conservative because constructs like
   // CleanupBlockInst are pretty easy to split.  However, SplitBlockPredecessors
   // cannot handle such things just yet.
-  if (FirstNonPHI->isEHPad())
-    return false;
-  return true;
+  return !FirstNonPHI->isEHPad();
 }
 
 /// This splits a basic block into two at the specified


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9974.38325.patch
Type: text/x-patch
Size: 2062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151024/d40785e1/attachment.bin>


More information about the llvm-commits mailing list