[llvm] r243734 - Refactor: Simplify boolean conditional return statements in lib/Target/NVPTX
Jingyue Wu
jingyue at google.com
Thu Jul 30 22:09:47 PDT 2015
Author: jingyue
Date: Fri Jul 31 00:09:47 2015
New Revision: 243734
URL: http://llvm.org/viewvc/llvm-project?rev=243734&view=rev
Log:
Refactor: Simplify boolean conditional return statements in lib/Target/NVPTX
Summary: Use clang-tidy to simplify boolean conditional return statements
Reviewers: rafael, echristo, chandlerc, bkramer, craig.topper, dexonsmith, chapuni, eliben, jingyue, jholewinski
Subscribers: llvm-commits, jholewinski
Differential Revision: http://reviews.llvm.org/D9983
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=243734&r1=243733&r2=243734&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Fri Jul 31 00:09:47 2015
@@ -635,9 +635,7 @@ static bool usedInGlobalVarDef(const Con
return false;
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
- if (GV->getName() == "llvm.used")
- return false;
- return true;
+ return GV->getName() != "llvm.used";
}
for (const User *U : C->users())
@@ -1955,12 +1953,9 @@ bool NVPTXAsmPrinter::isImageType(const
std::map<const Type *, std::string>::iterator PI = TypeNameMap.find(Ty);
- if (PI != TypeNameMap.end() && (!PI->second.compare("struct._image1d_t") ||
- !PI->second.compare("struct._image2d_t") ||
- !PI->second.compare("struct._image3d_t")))
- return true;
-
- return false;
+ return PI != TypeNameMap.end() && (!PI->second.compare("struct._image1d_t") ||
+ !PI->second.compare("struct._image2d_t") ||
+ !PI->second.compare("struct._image3d_t"));
}
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=243734&r1=243733&r2=243734&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Fri Jul 31 00:09:47 2015
@@ -3747,9 +3747,7 @@ bool NVPTXTargetLowering::isLegalAddress
// - [immAddr]
if (AM.BaseGV) {
- if (AM.BaseOffs || AM.HasBaseReg || AM.Scale)
- return false;
- return true;
+ return !AM.BaseOffs && !AM.HasBaseReg && !AM.Scale;
}
switch (AM.Scale) {
@@ -4113,25 +4111,16 @@ static bool AreMulWideOperandsDemotable(
if (ConstantSDNode *CI = dyn_cast<ConstantSDNode>(RHS)) {
APInt Val = CI->getAPIntValue();
if (LHSSign == Unsigned) {
- if (Val.isIntN(OptSize)) {
- return true;
- }
- return false;
+ return Val.isIntN(OptSize);
} else {
- if (Val.isSignedIntN(OptSize)) {
- return true;
- }
- return false;
+ return Val.isSignedIntN(OptSize);
}
} else {
OperandSignedness RHSSign;
if (!IsMulWideOperandDemotable(RHS, OptSize, RHSSign))
return false;
- if (LHSSign != RHSSign)
- return false;
-
- return true;
+ return LHSSign == RHSSign;
}
}
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp?rev=243734&r1=243733&r2=243734&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXUtilities.cpp Fri Jul 31 00:09:47 2015
@@ -336,18 +336,16 @@ bool llvm::getAlign(const CallInst &I, u
}
bool llvm::isBarrierIntrinsic(Intrinsic::ID id) {
- if ((id == Intrinsic::nvvm_barrier0) ||
- (id == Intrinsic::nvvm_barrier0_popc) ||
- (id == Intrinsic::nvvm_barrier0_and) ||
- (id == Intrinsic::nvvm_barrier0_or) ||
- (id == Intrinsic::cuda_syncthreads))
- return true;
- return false;
+ return (id == Intrinsic::nvvm_barrier0) ||
+ (id == Intrinsic::nvvm_barrier0_popc) ||
+ (id == Intrinsic::nvvm_barrier0_and) ||
+ (id == Intrinsic::nvvm_barrier0_or) ||
+ (id == Intrinsic::cuda_syncthreads);
}
// Interface for checking all memory space transfer related intrinsics
bool llvm::isMemorySpaceTransferIntrinsic(Intrinsic::ID id) {
- if (id == Intrinsic::nvvm_ptr_local_to_gen ||
+ return id == Intrinsic::nvvm_ptr_local_to_gen ||
id == Intrinsic::nvvm_ptr_shared_to_gen ||
id == Intrinsic::nvvm_ptr_global_to_gen ||
id == Intrinsic::nvvm_ptr_constant_to_gen ||
@@ -355,11 +353,7 @@ bool llvm::isMemorySpaceTransferIntrinsi
id == Intrinsic::nvvm_ptr_gen_to_shared ||
id == Intrinsic::nvvm_ptr_gen_to_local ||
id == Intrinsic::nvvm_ptr_gen_to_constant ||
- id == Intrinsic::nvvm_ptr_gen_to_param) {
- return true;
- }
-
- return false;
+ id == Intrinsic::nvvm_ptr_gen_to_param;
}
// consider several special intrinsics in striping pointer casts, and
More information about the llvm-commits
mailing list