Refactor: Simplify boolean expressions in llvm IR

Simplify boolean expressions using `true` and `false` with `clang-tidy`

Patch by Richard Thomson with a few other simplifications to fix
else-after-returns in the surrounding code.

Differential Revision: http://reviews.llvm.org/D8527

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2015-03-23 19:51:23 +00:00
parent b370250f03
commit 16ff2dadb0

View File

@ -2529,44 +2529,38 @@ bool CastInst::isCastable(Type *SrcTy, Type *DestTy) {
// Run through the possibilities ...
if (DestTy->isIntegerTy()) { // Casting to integral
if (SrcTy->isIntegerTy()) { // Casting from integral
if (SrcTy->isIntegerTy()) // Casting from integral
return true;
} else if (SrcTy->isFloatingPointTy()) { // Casting from floating pt
if (SrcTy->isFloatingPointTy()) // Casting from floating pt
return true;
} else if (SrcTy->isVectorTy()) { // Casting from vector
if (SrcTy->isVectorTy()) // Casting from vector
return DestBits == SrcBits;
} else { // Casting from something else
return SrcTy->isPointerTy();
}
} else if (DestTy->isFloatingPointTy()) { // Casting to floating pt
if (SrcTy->isIntegerTy()) { // Casting from integral
// Casting from something else
return SrcTy->isPointerTy();
}
if (DestTy->isFloatingPointTy()) { // Casting to floating pt
if (SrcTy->isIntegerTy()) // Casting from integral
return true;
} else if (SrcTy->isFloatingPointTy()) { // Casting from floating pt
if (SrcTy->isFloatingPointTy()) // Casting from floating pt
return true;
} else if (SrcTy->isVectorTy()) { // Casting from vector
if (SrcTy->isVectorTy()) // Casting from vector
return DestBits == SrcBits;
} else { // Casting from something else
return false;
}
} else if (DestTy->isVectorTy()) { // Casting to vector
return DestBits == SrcBits;
} else if (DestTy->isPointerTy()) { // Casting to pointer
if (SrcTy->isPointerTy()) { // Casting from pointer
return true;
} else if (SrcTy->isIntegerTy()) { // Casting from integral
return true;
} else { // Casting from something else
return false;
}
} else if (DestTy->isX86_MMXTy()) {
if (SrcTy->isVectorTy()) {
return DestBits == SrcBits; // 64-bit vector to MMX
} else {
return false;
}
} else { // Casting to something else
// Casting from something else
return false;
}
if (DestTy->isVectorTy()) // Casting to vector
return DestBits == SrcBits;
if (DestTy->isPointerTy()) { // Casting to pointer
if (SrcTy->isPointerTy()) // Casting from pointer
return true;
return SrcTy->isIntegerTy(); // Casting from integral
}
if (DestTy->isX86_MMXTy()) {
if (SrcTy->isVectorTy())
return DestBits == SrcBits; // 64-bit vector to MMX
return false;
} // Casting to something else
return false;
}
bool CastInst::isBitCastable(Type *SrcTy, Type *DestTy) {