summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-12-14 22:07:19 +0000
committerAndrew Trick <atrick@apple.com>2011-12-14 22:07:19 +0000
commite0ced62119ff1a28bf32fdd23a29b94056c34bef (patch)
tree800f82ffabc2b0a420c655c1f281434416836003 /llvm/lib/Analysis
parent9af58d44269149e169cf7136763cc4f20dbef03d (diff)
downloadbcm5719-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.cpp11
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())) {
OpenPOWER on IntegriCloud