diff options
| author | Nadav Rotem <nadav.rotem@intel.com> | 2011-08-28 11:51:08 +0000 |
|---|---|---|
| committer | Nadav Rotem <nadav.rotem@intel.com> | 2011-08-28 11:51:08 +0000 |
| commit | 52600ee8c3ed94fb69d6147a640a330e3d7b00ed (patch) | |
| tree | a99b6063ecbb65cc2432da8726ef1a58169a11ff /llvm/lib/Analysis/ConstantFolding.cpp | |
| parent | 5d8f912f50831684e22d525e5d11477eaff6ef31 (diff) | |
| download | bcm5719-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/Analysis/ConstantFolding.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index df79849c3cf..613804d6d2d 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -51,6 +51,12 @@ static Constant *FoldBitCast(Constant *C, Type *DestTy, if (C->isAllOnesValue() && !DestTy->isX86_MMXTy()) return Constant::getAllOnesValue(DestTy); + // Bitcast of Bitcast can be done using a single cast. + ConstantExpr *CE = dyn_cast<ConstantExpr>(C); + if (CE && CE->getOpcode() == Instruction::BitCast) { + return ConstantExpr::getBitCast(CE->getOperand(0), DestTy); + } + // The code below only handles casts to vectors currently. VectorType *DestVTy = dyn_cast<VectorType>(DestTy); if (DestVTy == 0) |

