summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Expressions.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-11-26 16:53:50 +0000
committerChris Lattner <sabre@nondot.org>2001-11-26 16:53:50 +0000
commit0ae45bd3f41f00db2eb53f3e8f3fd96aa16477d7 (patch)
tree0338471619c0fdf994d33fe2fa66bc5b898266ad /llvm/lib/Analysis/Expressions.cpp
parente1531446aa667ec96e856ef6ee9355400d5ab240 (diff)
downloadbcm5719-llvm-0ae45bd3f41f00db2eb53f3e8f3fd96aa16477d7.tar.gz
bcm5719-llvm-0ae45bd3f41f00db2eb53f3e8f3fd96aa16477d7.zip
* Implement more powerful expr analysis of cast instructions
llvm-svn: 1335
Diffstat (limited to 'llvm/lib/Analysis/Expressions.cpp')
-rw-r--r--llvm/lib/Analysis/Expressions.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/Expressions.cpp b/llvm/lib/Analysis/Expressions.cpp
index ed04f1d818a..dd922124969 100644
--- a/llvm/lib/Analysis/Expressions.cpp
+++ b/llvm/lib/Analysis/Expressions.cpp
@@ -284,21 +284,30 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
case Instruction::Cast: {
ExprType Src(ClassifyExpression(I->getOperand(0)));
- if (Src.ExprTy != ExprType::Constant)
- return I;
- const ConstPoolInt *Offs = Src.Offset;
- if (Offs == 0) return ExprType();
-
const Type *DestTy = I->getType();
if (DestTy->isPointerType())
DestTy = Type::ULongTy; // Pointer types are represented as ulong
- assert(DestTy->isIntegral() && "Can only handle integral types!");
-
- const ConstPoolVal *CPV =ConstRules::get(*Offs)->castTo(Offs, DestTy);
- if (!CPV) return I;
- assert(CPV->getType()->isIntegral() && "Must have an integral type!");
- return cast<ConstPoolInt>(CPV);
+ /*
+ if (!Src.getExprType(0)->isLosslesslyConvertableTo(DestTy)) {
+ if (Src.ExprTy != ExprType::Constant)
+ return I; // Converting cast, and not a constant value...
+ }
+ */
+
+ const ConstPoolInt *Offset = Src.Offset;
+ const ConstPoolInt *Scale = Src.Scale;
+ if (Offset) {
+ const ConstPoolVal *CPV = ConstantFoldCastInstruction(Offset, DestTy);
+ if (!CPV) return I;
+ Offset = cast<ConstPoolInt>(CPV);
+ }
+ if (Scale) {
+ const ConstPoolVal *CPV = ConstantFoldCastInstruction(Scale, DestTy);
+ if (!CPV) return I;
+ Scale = cast<ConstPoolInt>(CPV);
+ }
+ return ExprType(Scale, Src.Var, Offset);
} // end case Instruction::Cast
// TODO: Handle SUB, SHR?
OpenPOWER on IntegriCloud