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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243734 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jingyue Wu 2015-07-31 05:09:47 +00:00
parent 30eac4b85a
commit c71235ab7d
3 changed files with 15 additions and 37 deletions

View File

@ -635,9 +635,7 @@ static bool usedInGlobalVarDef(const Constant *C) {
return false; return false;
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) { if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
if (GV->getName() == "llvm.used") return GV->getName() != "llvm.used";
return false;
return true;
} }
for (const User *U : C->users()) for (const User *U : C->users())
@ -1955,12 +1953,9 @@ bool NVPTXAsmPrinter::isImageType(const Type *Ty) {
std::map<const Type *, std::string>::iterator PI = TypeNameMap.find(Ty); std::map<const Type *, std::string>::iterator PI = TypeNameMap.find(Ty);
if (PI != TypeNameMap.end() && (!PI->second.compare("struct._image1d_t") || return PI != TypeNameMap.end() && (!PI->second.compare("struct._image1d_t") ||
!PI->second.compare("struct._image2d_t") || !PI->second.compare("struct._image2d_t") ||
!PI->second.compare("struct._image3d_t"))) !PI->second.compare("struct._image3d_t"));
return true;
return false;
} }

View File

@ -3747,9 +3747,7 @@ bool NVPTXTargetLowering::isLegalAddressingMode(const DataLayout &DL,
// - [immAddr] // - [immAddr]
if (AM.BaseGV) { if (AM.BaseGV) {
if (AM.BaseOffs || AM.HasBaseReg || AM.Scale) return !AM.BaseOffs && !AM.HasBaseReg && !AM.Scale;
return false;
return true;
} }
switch (AM.Scale) { switch (AM.Scale) {
@ -4113,25 +4111,16 @@ static bool AreMulWideOperandsDemotable(SDValue LHS, SDValue RHS,
if (ConstantSDNode *CI = dyn_cast<ConstantSDNode>(RHS)) { if (ConstantSDNode *CI = dyn_cast<ConstantSDNode>(RHS)) {
APInt Val = CI->getAPIntValue(); APInt Val = CI->getAPIntValue();
if (LHSSign == Unsigned) { if (LHSSign == Unsigned) {
if (Val.isIntN(OptSize)) { return Val.isIntN(OptSize);
return true;
}
return false;
} else { } else {
if (Val.isSignedIntN(OptSize)) { return Val.isSignedIntN(OptSize);
return true;
}
return false;
} }
} else { } else {
OperandSignedness RHSSign; OperandSignedness RHSSign;
if (!IsMulWideOperandDemotable(RHS, OptSize, RHSSign)) if (!IsMulWideOperandDemotable(RHS, OptSize, RHSSign))
return false; return false;
if (LHSSign != RHSSign) return LHSSign == RHSSign;
return false;
return true;
} }
} }

View File

@ -336,18 +336,16 @@ bool llvm::getAlign(const CallInst &I, unsigned index, unsigned &align) {
} }
bool llvm::isBarrierIntrinsic(Intrinsic::ID id) { bool llvm::isBarrierIntrinsic(Intrinsic::ID id) {
if ((id == Intrinsic::nvvm_barrier0) || return (id == Intrinsic::nvvm_barrier0) ||
(id == Intrinsic::nvvm_barrier0_popc) || (id == Intrinsic::nvvm_barrier0_popc) ||
(id == Intrinsic::nvvm_barrier0_and) || (id == Intrinsic::nvvm_barrier0_and) ||
(id == Intrinsic::nvvm_barrier0_or) || (id == Intrinsic::nvvm_barrier0_or) ||
(id == Intrinsic::cuda_syncthreads)) (id == Intrinsic::cuda_syncthreads);
return true;
return false;
} }
// Interface for checking all memory space transfer related intrinsics // Interface for checking all memory space transfer related intrinsics
bool llvm::isMemorySpaceTransferIntrinsic(Intrinsic::ID id) { 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_shared_to_gen ||
id == Intrinsic::nvvm_ptr_global_to_gen || id == Intrinsic::nvvm_ptr_global_to_gen ||
id == Intrinsic::nvvm_ptr_constant_to_gen || id == Intrinsic::nvvm_ptr_constant_to_gen ||
@ -355,11 +353,7 @@ bool llvm::isMemorySpaceTransferIntrinsic(Intrinsic::ID id) {
id == Intrinsic::nvvm_ptr_gen_to_shared || id == Intrinsic::nvvm_ptr_gen_to_shared ||
id == Intrinsic::nvvm_ptr_gen_to_local || id == Intrinsic::nvvm_ptr_gen_to_local ||
id == Intrinsic::nvvm_ptr_gen_to_constant || id == Intrinsic::nvvm_ptr_gen_to_constant ||
id == Intrinsic::nvvm_ptr_gen_to_param) { id == Intrinsic::nvvm_ptr_gen_to_param;
return true;
}
return false;
} }
// consider several special intrinsics in striping pointer casts, and // consider several special intrinsics in striping pointer casts, and