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 | 1baace07c498dd50e9c08f40e83b43fd5a8b2954 (patch) | |
| tree | 6792bca963500a298e0888226e4d1ce5ba629132 /llvm | |
| parent | c3d79cf6b3b16ec1fbc884c0948fa0a76dc123bc (diff) | |
| download | bcm5719-llvm-1baace07c498dd50e9c08f40e83b43fd5a8b2954.tar.gz bcm5719-llvm-1baace07c498dd50e9c08f40e83b43fd5a8b2954.zip | |
apply Eli's patch for PR2165 and provide a testcase.
llvm-svn: 57625
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/Transforms/ConstProp/bitcast2.ll | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 93ee7fe59ae..fcbda21451b 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/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/llvm/test/Transforms/ConstProp/bitcast2.ll b/llvm/test/Transforms/ConstProp/bitcast2.ll new file mode 100644 index 00000000000..66def7f49da --- /dev/null +++ b/llvm/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 +} + |

