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

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 28 23:32:01 PST 2003


Changes in directory llvm/lib/Transforms:

ExprTypeConvert.cpp updated: 1.83 -> 1.84

---
Log message:

Fix test: Transforms/LevelRaise/2003-11-28-IllegalTypeConversion.ll
Some gep generalization changes


---
Diffs of the changes:  (+7 -6)

Index: llvm/lib/Transforms/ExprTypeConvert.cpp
diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.83 llvm/lib/Transforms/ExprTypeConvert.cpp:1.84
--- llvm/lib/Transforms/ExprTypeConvert.cpp:1.83	Tue Nov 11 16:41:33 2003
+++ llvm/lib/Transforms/ExprTypeConvert.cpp	Fri Nov 28 23:31:25 2003
@@ -257,7 +257,6 @@
     // and we could convert this to an appropriate GEP for the new type.
     //
     if (GEP->getNumOperands() == 2 &&
-        GEP->getOperand(1)->getType() == Type::LongTy &&
         GEP->getType() == PointerType::get(Type::SByteTy)) {
 
       // Do not Check to see if our incoming pointer can be converted
@@ -285,7 +284,6 @@
     //     getelemenptr [[int] *] * %reg115, long %reg138      ; [int]**
     //
     if (GEP->getNumOperands() == 2 && 
-        GEP->getOperand(1)->getType() == Type::LongTy &&
         PTy->getElementType()->isSized() &&
         TD.getTypeSize(PTy->getElementType()) == 
         TD.getTypeSize(GEP->getType()->getElementType())) {
@@ -466,11 +464,10 @@
     }
 
     if (Res == 0 && GEP->getNumOperands() == 2 &&
-        GEP->getOperand(1)->getType() == Type::LongTy &&
         GEP->getType() == PointerType::get(Type::SByteTy)) {
       
       // Otherwise, we can convert a GEP from one form to the other iff the
-      // current gep is of the form 'getelementptr [sbyte]*, unsigned N
+      // current gep is of the form 'getelementptr sbyte*, unsigned N
       // and we could convert this to an appropriate GEP for the new type.
       //
       const PointerType *NewSrcTy = PointerType::get(PVTy);
@@ -774,8 +771,12 @@
           TD.getTypeSize(ElTy) != TD.getTypeSize(I->getOperand(0)->getType()))
         return false;
 
-      // Can convert store if the incoming value is convertible...
-      return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
+      // Can convert store if the incoming value is convertible and if the
+      // result will preserve semantics...
+      const Type *Op0Ty = I->getOperand(0)->getType();
+      if (!(Op0Ty->isIntegral() ^ ElTy->isIntegral()) &&
+          !(Op0Ty->isFloatingPoint() ^ ElTy->isFloatingPoint()))
+        return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
     }
     return false;
   }





More information about the llvm-commits mailing list