The word `separate' only has one `e'.
[oota-llvm.git] / lib / Analysis / Expressions.cpp
index 7901b1421e5c34a4f284dde5de39b14b8607851f..f1016a50dbe70f6d3a3bee00adf38dd1fe721e19 100644 (file)
@@ -30,7 +30,7 @@ ExprType::ExprType(const ConstantInt *scale, Value *var,
                   const ConstantInt *offset) {
   Scale = var ? scale : 0; Var = var; Offset = offset;
   ExprTy = Scale ? ScaledLinear : (Var ? Linear : Constant);
-  if (Scale && Scale->equalsInt(0)) {  // Simplify 0*Var + const
+  if (Scale && Scale->isNullValue()) {  // Simplify 0*Var + const
     Scale = 0; Var = 0;
     ExprTy = Constant;
   }
@@ -244,18 +244,16 @@ ExprType ClassifyExpression(Value *Expr) {
   case Value::ArgumentVal:              // nothing known, return variable itself
     return Expr;
   case Value::ConstantVal:              // Constant value, just return constant
-    Constant *CPV = cast<Constant>(Expr);
-    if (CPV->getType()->isIntegral()) { // It's an integral constant!
-      ConstantInt *CPI = cast<ConstantInt>(Expr);
-      return ExprType(CPI->equalsInt(0) ? 0 : CPI);
-    }
+    if (ConstantInt *CPI = dyn_cast<ConstantInt>(cast<Constant>(Expr)))
+      // It's an integral constant!
+      return ExprType(CPI->isNullValue() ? 0 : CPI);
     return Expr;
   }
   
   Instruction *I = cast<Instruction>(Expr);
   const Type *Ty = I->getType();
 
-  switch (I->getOpcode()) {       // Handle each instruction type seperately
+  switch (I->getOpcode()) {       // Handle each instruction type separately
   case Instruction::Add: {
     ExprType Left (ClassifyExpression(I->getOperand(0)));
     ExprType Right(ClassifyExpression(I->getOperand(1)));
@@ -319,12 +317,12 @@ ExprType ClassifyExpression(Value *Expr) {
     if (isa<PointerType>(DestTy))
       DestTy = Type::ULongTy;  // Pointer types are represented as ulong
 
-    /*
-    if (!Src.getExprType(0)->isLosslesslyConvertableTo(DestTy)) {
+    const Type *SrcValTy = Src.getExprType(0);
+    if (!SrcValTy) return I;
+    if (!SrcValTy->isLosslesslyConvertibleTo(DestTy)) {
       if (Src.ExprTy != ExprType::Constant)
         return I;  // Converting cast, and not a constant value...
     }
-    */
 
     const ConstantInt *Offset = Src.Offset;
     const ConstantInt *Scale  = Src.Scale;