[llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
Reid Spencer
reid at x10sys.com
Wed Dec 13 00:07:02 PST 2006
Changes in directory llvm/include/llvm/Analysis:
ScalarEvolutionExpander.h updated: 1.9 -> 1.10
---
Log message:
Change the interface to SCEVExpander::InsertCastOfTo to take a cast opcode
so the decision of which opcode to use is pushed upward to the caller.
Adjust the callers to pass the expected opcode.
---
Diffs of the changes: (+17 -4)
ScalarEvolutionExpander.h | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
Index: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h
diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.9 llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.10
--- llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.9 Mon Dec 4 14:18:26 2006
+++ llvm/include/llvm/Analysis/ScalarEvolutionExpander.h Wed Dec 13 02:06:42 2006
@@ -88,7 +88,8 @@
/// InsertCastOfTo - Insert a cast of V to the specified type, doing what
/// we can to share the casts.
- static Value *InsertCastOfTo(Value *V, const Type *Ty);
+ static Value *InsertCastOfTo(Instruction::CastOps opcode, Value *V,
+ const Type *Ty);
protected:
Value *expand(SCEV *S) {
@@ -104,8 +105,20 @@
Value *expandInTy(SCEV *S, const Type *Ty) {
Value *V = expand(S);
- if (Ty && V->getType() != Ty)
- return InsertCastOfTo(V, Ty);
+ if (Ty && V->getType() != Ty) {
+ if (isa<PointerType>(Ty) && V->getType()->isInteger())
+ return InsertCastOfTo(Instruction::IntToPtr, V, Ty);
+ else if (Ty->isInteger() && isa<PointerType>(V->getType()))
+ return InsertCastOfTo(Instruction::PtrToInt, V, Ty);
+ else if (Ty->getPrimitiveSizeInBits() ==
+ V->getType()->getPrimitiveSizeInBits())
+ return InsertCastOfTo(Instruction::BitCast, V, Ty);
+ else if (Ty->getPrimitiveSizeInBits() >
+ V->getType()->getPrimitiveSizeInBits())
+ return InsertCastOfTo(Instruction::ZExt, V, Ty);
+ else
+ return InsertCastOfTo(Instruction::Trunc, V, Ty);
+ }
return V;
}
@@ -119,7 +132,7 @@
}
Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
- Value *V = expandInTy(S->getOperand(),S->getType()->getUnsignedVersion());
+ Value *V = expandInTy(S->getOperand(), S->getType());
return CastInst::createZExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
}
More information about the llvm-commits
mailing list