aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-04 05:46:37 +0000
committerChris Lattner <sabre@nondot.org>2002-11-04 05:46:37 +0000
commit38dc4f06af12a16efb52ee09d63182cd6a1775c6 (patch)
tree7dcd5478ac447ad55fcc06d9d60522a87a9bb0a0 /lib/Transforms
parentf74825436c2a62ae16874465479a02b2859f216e (diff)
Be more generous about level raising constant expressions don't force each
constant to one particular type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 28b92896a8..aa183d24eb 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -139,22 +139,18 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
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 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
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();