[llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Nov 3 23:47:01 PST 2002


Changes in directory llvm/lib/Transforms:

ExprTypeConvert.cpp updated: 1.63 -> 1.64

---
Log message:

Be more generous about level raising constant expressions don't force each 
constant to one particular type.


---
Diffs of the changes:

Index: llvm/lib/Transforms/ExprTypeConvert.cpp
diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.63 llvm/lib/Transforms/ExprTypeConvert.cpp:1.64
--- llvm/lib/Transforms/ExprTypeConvert.cpp:1.63	Thu Oct 31 22:49:06 2002
+++ llvm/lib/Transforms/ExprTypeConvert.cpp	Sun Nov  3 23:46:37 2002
@@ -139,22 +139,18 @@
   ValueTypeCache::iterator CTMI = CTMap.find(V);
   if (CTMI != CTMap.end()) return CTMI->second == Ty;
 
+  // If it's a constant... all constants can be converted to a different type We
+  // just ask the constant propogator to see if it can convert the value...
+  //
+  if (Constant *CPV = dyn_cast<Constant>(V))
+    return ConstantFoldCastInstruction(CPV, Ty);
+  
+
   CTMap[V] = Ty;
   if (V->getType() == Ty) return true;  // Expression already correct type!
 
   Instruction *I = dyn_cast<Instruction>(V);
-  if (I == 0) {
-    // It's not an instruction, check to see if it's a constant... all constants
-    // can be converted to an equivalent value (except pointers, they can't be
-    // const prop'd in general).  We just ask the constant propogator to see if
-    // it can convert the value...
-    //
-    if (Constant *CPV = dyn_cast<Constant>(V))
-      if (ConstantFoldCastInstruction(CPV, Ty))
-        return true;  // Don't worry about deallocating, it's a constant.
-
-    return false;              // Otherwise, we can't convert!
-  }
+  if (I == 0) return false;              // Otherwise, we can't convert!
 
   switch (I->getOpcode()) {
   case Instruction::Cast:
@@ -323,18 +319,18 @@
   DEBUG(cerr << "CETT: " << (void*)V << " " << V);
 
   Instruction *I = dyn_cast<Instruction>(V);
-  if (I == 0)
-    if (Constant *CPV = cast<Constant>(V)) {
-      // Constants are converted by constant folding the cast that is required.
-      // We assume here that all casts are implemented for constant prop.
-      Value *Result = ConstantFoldCastInstruction(CPV, Ty);
-      assert(Result && "ConstantFoldCastInstruction Failed!!!");
-      assert(Result->getType() == Ty && "Const prop of cast failed!");
-
-      // Add the instruction to the expression map
-      VMC.ExprMap[V] = Result;
-      return Result;
-    }
+  if (I == 0) {
+    Constant *CPV = cast<Constant>(V)) {
+    // Constants are converted by constant folding the cast that is required.
+    // We assume here that all casts are implemented for constant prop.
+    Value *Result = ConstantFoldCastInstruction(CPV, Ty);
+    assert(Result && "ConstantFoldCastInstruction Failed!!!");
+    assert(Result->getType() == Ty && "Const prop of cast failed!");
+
+    // Add the instruction to the expression map
+    //VMC.ExprMap[V] = Result;
+    return Result;
+  }
 
 
   BasicBlock *BB = I->getParent();





More information about the llvm-commits mailing list