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 | e0ced62119ff1a28bf32fdd23a29b94056c34bef (patch) | |
tree | 800f82ffabc2b0a420c655c1f281434416836003 /llvm/lib/Analysis | |
parent | 9af58d44269149e169cf7136763cc4f20dbef03d (diff) | |
download | bcm5719-llvm-e0ced62119ff1a28bf32fdd23a29b94056c34bef.tar.gz bcm5719-llvm-e0ced62119ff1a28bf32fdd23a29b94056c34bef.zip |
LSR: Fold redundant bitcasts on-the-fly.
llvm-svn: 146597
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 59901aaa839..f3cf5494551 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/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())) { |