[llvm] r233005 - Refactor: Simplify boolean expressions in llvm IR
David Blaikie
dblaikie at gmail.com
Mon Mar 23 12:51:23 PDT 2015
Author: dblaikie
Date: Mon Mar 23 14:51:23 2015
New Revision: 233005
URL: http://llvm.org/viewvc/llvm-project?rev=233005&view=rev
Log:
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
Modified:
llvm/trunk/lib/IR/Instructions.cpp
Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=233005&r1=233004&r2=233005&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Mon Mar 23 14:51:23 2015
@@ -2529,44 +2529,38 @@ bool CastInst::isCastable(Type *SrcTy, T
// 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
+ // Casting from something else
+ return false;
+ }
+ if (DestTy->isVectorTy()) // Casting to vector
return DestBits == SrcBits;
- } else if (DestTy->isPointerTy()) { // Casting to pointer
- if (SrcTy->isPointerTy()) { // Casting from pointer
+ 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 SrcTy->isIntegerTy(); // Casting from integral
+ }
+ if (DestTy->isX86_MMXTy()) {
+ if (SrcTy->isVectorTy())
return DestBits == SrcBits; // 64-bit vector to MMX
- } else {
- return false;
- }
- } else { // Casting to something else
return false;
- }
+ } // Casting to something else
+ return false;
}
bool CastInst::isBitCastable(Type *SrcTy, Type *DestTy) {
More information about the llvm-commits
mailing list