apply Eli's patch for PR2165 and provide a testcase.

llvm-svn: 57625
This commit is contained in:
Chris Lattner 2008-10-16 05:26:51 +00:00
parent c3d79cf6b3
commit 1baace07c4
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,8 @@
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep bitcast
; PR2165
define <1 x i64> @test() {
%A = bitcast i64 63 to <1 x i64>
ret <1 x i64> %A
}