aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-16 05:26:51 +0000
committerChris Lattner <sabre@nondot.org>2008-10-16 05:26:51 +0000
commit868510328fc0b25ca97f2fba466a77c2c4e29c45 (patch)
tree03db7e663b72703ab1019a660fcee949213c4eba /lib/VMCore/ConstantFold.cpp
parent8e8b8a223c2b0e69f44c0639f846260c8011668f (diff)
downloadexternal_llvm-868510328fc0b25ca97f2fba466a77c2c4e29c45.zip
external_llvm-868510328fc0b25ca97f2fba466a77c2c4e29c45.tar.gz
external_llvm-868510328fc0b25ca97f2fba466a77c2c4e29c45.tar.bz2
apply Eli's patch for PR2165 and provide a testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 93ee7fe..fcbda21 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -133,6 +133,12 @@ static Constant *FoldBitCast(Constant *V, const Type *DestTy) {
if (ConstantVector *CV = dyn_cast<ConstantVector>(V))
return BitCastConstantVector(CV, DestPTy);
}
+
+ // Canonicalize scalar-to-vector bitcasts into vector-to-vector bitcasts
+ // This allows for other simplifications (although some of them
+ // can only be handled by Analysis/ConstantFolding.cpp).
+ if (isa<ConstantInt>(V) || isa<ConstantFP>(V))
+ return ConstantExpr::getBitCast(ConstantVector::get(&V, 1), DestPTy);
}
// Finally, implement bitcast folding now. The code below doesn't handle