diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 93ee7fe59a..fcbda21451 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 |