summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2011-08-23 17:48:43 +0000
committerNadav Rotem <nadav.rotem@intel.com>2011-08-23 17:48:43 +0000
commit20a05be15ea5271ab6185b83200fa88263362400 (patch)
tree11074688c788939245773956dcff96318752fe2f /lib/Analysis
parent6153a036f544beb03dfc4d58edc28cf42712743d (diff)
downloadllvm-20a05be15ea5271ab6185b83200fa88263362400.tar.gz
llvm-20a05be15ea5271ab6185b83200fa88263362400.tar.bz2
llvm-20a05be15ea5271ab6185b83200fa88263362400.tar.xz
Address Duncan's CR request:
1. Cleanup the tests in ConstantFolding.cpp 2. Implement isAllOnes for Constant, ConstantFP, ConstantVector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/ConstantFolding.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 7a8c703040..0eacaf8037 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -45,15 +45,9 @@ using namespace llvm;
/// ConstantExpr if unfoldable.
static Constant *FoldBitCast(Constant *C, Type *DestTy,
const TargetData &TD) {
-
- ConstantVector *CV = dyn_cast<ConstantVector>(C);
- IntegerType *IntVTy = dyn_cast<IntegerType>(DestTy);
- // When casting vectors to scalar integers, catch the
- // obvious splat cases.
- if (IntVTy && CV) {
- if (CV->isNullValue()) return ConstantInt::getNullValue(IntVTy);
- if (CV->isAllOnesValue()) return ConstantInt::getAllOnesValue(IntVTy);
- }
+ // Catch the obvious splat cases.
+ if (C->isNullValue()) return Constant::getNullValue(DestTy);
+ if (C->isAllOnesValue()) return Constant::getAllOnesValue(DestTy);
// The code below only handles casts to vectors currently.
VectorType *DestVTy = dyn_cast<VectorType>(DestTy);
@@ -68,6 +62,7 @@ static Constant *FoldBitCast(Constant *C, Type *DestTy,
}
// If this is a bitcast from constant vector -> vector, fold it.
+ ConstantVector *CV = dyn_cast<ConstantVector>(C);
if (CV == 0)
return ConstantExpr::getBitCast(C, DestTy);