aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-04-16 19:25:55 +0000
committerDan Gohman <gohman@apple.com>2009-04-16 19:25:55 +0000
commit8170a6849ed370059676f94d8a00ae652873a394 (patch)
tree36aef840f9443704bb9d58e8fd8f4eb7ecdaaba4 /lib/Analysis/ScalarEvolutionExpander.cpp
parent02f8c410148ba3b6009ed67df41e2c97c1c07c3a (diff)
Fix a bug with inttoptr/ptrtoint casts where the pointer has a different
size from the integer, requiring zero extension or truncation. Don't create ZExtInsts with pointer types. This fixes a regression in consumer-jpeg. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69307 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--lib/Analysis/ScalarEvolutionExpander.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp
index 6300f1ff11..0e0eb55a05 100644
--- a/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -281,17 +281,21 @@ Value *SCEVExpander::visitTruncateExpr(SCEVTruncateExpr *S) {
}
Value *SCEVExpander::visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
+ const Type *Ty = S->getType();
+ if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
Value *V = expand(S->getOperand());
if (isa<PointerType>(V->getType()))
V = InsertCastOfTo(Instruction::PtrToInt, V, TD.getIntPtrType());
- return CastInst::CreateZExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
+ return CastInst::CreateZExtOrBitCast(V, Ty, "tmp.", InsertPt);
}
Value *SCEVExpander::visitSignExtendExpr(SCEVSignExtendExpr *S) {
+ const Type *Ty = S->getType();
+ if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
Value *V = expand(S->getOperand());
if (isa<PointerType>(V->getType()))
V = InsertCastOfTo(Instruction::PtrToInt, V, TD.getIntPtrType());
- return CastInst::CreateSExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
+ return CastInst::CreateSExtOrBitCast(V, Ty, "tmp.", InsertPt);
}
Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) {