summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2011-08-28 11:51:08 +0000
committerNadav Rotem <nadav.rotem@intel.com>2011-08-28 11:51:08 +0000
commit52600ee8c3ed94fb69d6147a640a330e3d7b00ed (patch)
treea99b6063ecbb65cc2432da8726ef1a58169a11ff /llvm/lib/Transforms
parent5d8f912f50831684e22d525e5d11477eaff6ef31 (diff)
downloadbcm5719-llvm-52600ee8c3ed94fb69d6147a640a330e3d7b00ed.tar.gz
bcm5719-llvm-52600ee8c3ed94fb69d6147a640a330e3d7b00ed.zip
Bitcasts are transitive. Bitcast-Bitcast-X becomes Bitcast-X.
llvm-svn: 138722
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index ba90bf6b5c5..6c42c0c6600 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1659,6 +1659,11 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
if (DestTy == Src->getType())
return ReplaceInstUsesWith(CI, Src);
+ // Bitcasts are transitive.
+ if (BitCastInst* BSrc = dyn_cast<BitCastInst>(Src)) {
+ return CastInst::Create(Instruction::BitCast, BSrc->getOperand(0), DestTy);
+ }
+
if (PointerType *DstPTy = dyn_cast<PointerType>(DestTy)) {
PointerType *SrcPTy = cast<PointerType>(SrcTy);
Type *DstElTy = DstPTy->getElementType();
OpenPOWER on IntegriCloud