summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine
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
commitbe6ceb6ebcfb48e09ffab297c1537c87383f0ce9 (patch)
treee05e876a1b8886b72f3abe66192ec5fdcbfe0cfa /lib/Transforms/InstCombine
parentb1b051ec97c4e3c02cea554e169cbb4f85bcb2de (diff)
downloadllvm-be6ceb6ebcfb48e09ffab297c1537c87383f0ce9.tar.gz
llvm-be6ceb6ebcfb48e09ffab297c1537c87383f0ce9.tar.bz2
llvm-be6ceb6ebcfb48e09ffab297c1537c87383f0ce9.tar.xz
Bitcasts are transitive. Bitcast-Bitcast-X becomes Bitcast-X.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCasts.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index ba90bf6b5c..6c42c0c660 100644
--- a/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/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();