[llvm-commits] [llvm] r57625 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/ConstProp/bitcast2.ll
Chris Lattner
sabre at nondot.org
Wed Oct 15 22:26:52 PDT 2008
Author: lattner
Date: Thu Oct 16 00:26:51 2008
New Revision: 57625
URL: http://llvm.org/viewvc/llvm-project?rev=57625&view=rev
Log:
apply Eli's patch for PR2165 and provide a testcase.
Added:
llvm/trunk/test/Transforms/ConstProp/bitcast2.ll
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=57625&r1=57624&r2=57625&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Thu Oct 16 00:26:51 2008
@@ -133,6 +133,12 @@
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
Added: llvm/trunk/test/Transforms/ConstProp/bitcast2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/bitcast2.ll?rev=57625&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/ConstProp/bitcast2.ll (added)
+++ llvm/trunk/test/Transforms/ConstProp/bitcast2.ll Thu Oct 16 00:26:51 2008
@@ -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
+}
+
More information about the llvm-commits
mailing list