[PATCH] Refactor: Simplify boolean conditional return statements in llvm/lib/IR
Richard
legalize at xmission.com
Mon May 25 07:12:52 PDT 2015
Update from comments, run clang-format
http://reviews.llvm.org/D9974
Files:
lib/IR/ConstantFold.cpp
lib/IR/InlineAsm.cpp
lib/IR/Instructions.cpp
lib/IR/Verifier.cpp
Index: lib/IR/ConstantFold.cpp
===================================================================
--- lib/IR/ConstantFold.cpp
+++ lib/IR/ConstantFold.cpp
@@ -2020,11 +2020,8 @@
// A negative index or an index past the end of our sequential type is
// considered out-of-range.
int64_t IndexVal = CI->getSExtValue();
- if (IndexVal < 0 || (NumElements > 0 && (uint64_t)IndexVal >= NumElements))
- return false;
-
- // Otherwise, it is in-range.
- return true;
+ return !(IndexVal < 0 ||
+ (NumElements > 0 && (uint64_t)IndexVal >= NumElements));
}
template<typename IndexTy>
Index: lib/IR/InlineAsm.cpp
===================================================================
--- lib/IR/InlineAsm.cpp
+++ lib/IR/InlineAsm.cpp
@@ -288,7 +288,6 @@
break;
}
- if (Ty->getNumParams() != NumInputs) return false;
- return true;
+ return Ty->getNumParams() == NumInputs;
}
Index: lib/IR/Instructions.cpp
===================================================================
--- lib/IR/Instructions.cpp
+++ lib/IR/Instructions.cpp
@@ -1372,9 +1372,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();
}
@@ -2602,10 +2600,7 @@
if (SrcBits != DestBits)
return false;
- if (DestTy->isX86_MMXTy() || SrcTy->isX86_MMXTy())
- return false;
-
- return true;
+ return !DestTy->isX86_MMXTy() && !SrcTy->isX86_MMXTy();
}
bool CastInst::isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy,
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -1510,12 +1510,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.
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9974.26434.patch
Type: text/x-patch
Size: 2359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150525/d3248ca7/attachment.bin>
More information about the llvm-commits
mailing list