diff options
author | Andrew Trick <atrick@apple.com> | 2011-12-14 22:07:19 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2011-12-14 22:07:19 +0000 |
commit | 19154f457696f286b4a597179fa07e3b38ea0310 (patch) | |
tree | 0ad2525feae032b2d819d91b97c0f940d563b96f /lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | ec04a3f8db9ab9db3bbec3ce32baaa2ea2cb853f (diff) |
LSR: Fold redundant bitcasts on-the-fly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 59901aaa83..f3cf549455 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -73,9 +73,14 @@ Value *SCEVExpander::InsertNoopCastOfTo(Value *V, Type *Ty) { "InsertNoopCastOfTo cannot change sizes!"); // Short-circuit unnecessary bitcasts. - if (Op == Instruction::BitCast && V->getType() == Ty) - return V; - + if (Op == Instruction::BitCast) { + if (V->getType() == Ty) + return V; + if (CastInst *CI = dyn_cast<CastInst>(V)) { + if (CI->getOperand(0)->getType() == Ty) + return CI->getOperand(0); + } + } // Short-circuit unnecessary inttoptr<->ptrtoint casts. if ((Op == Instruction::PtrToInt || Op == Instruction::IntToPtr) && SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(V->getType())) { |