diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-16 05:26:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-16 05:26:51 +0000 |
commit | 944ade928e8bd99b9465ef0e678a21227507f89b (patch) | |
tree | 03db7e663b72703ab1019a660fcee949213c4eba | |
parent | 46b948ea872c1d1853fc5be4af44794ef3ae7f63 (diff) | |
download | external_llvm-944ade928e8bd99b9465ef0e678a21227507f89b.zip external_llvm-944ade928e8bd99b9465ef0e678a21227507f89b.tar.gz external_llvm-944ade928e8bd99b9465ef0e678a21227507f89b.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
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 6 | ||||
-rw-r--r-- | test/Transforms/ConstProp/bitcast2.ll | 8 |
2 files changed, 14 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 diff --git a/test/Transforms/ConstProp/bitcast2.ll b/test/Transforms/ConstProp/bitcast2.ll new file mode 100644 index 0000000..66def7f --- /dev/null +++ b/test/Transforms/ConstProp/bitcast2.ll @@ -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 +} + |