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

Reid Spencer reid at x10sys.com
Fri Jan 19 13:20:47 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.604 -> 1.605
---
Log message:

For this transform: store V, (cast P) -> store (cast V), P
don't allow the transform if V and the pointer's element type are different
width integer types.



---
Diffs of the changes:  (+4 -3)

 InstructionCombining.cpp |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.604 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.605
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.604	Fri Jan 19 15:13:56 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Fri Jan 19 15:20:31 2007
@@ -8162,7 +8162,7 @@
   return 0;
 }
 
-/// InstCombineStoreToCast - Fold 'store V, (cast P)' -> store (cast V), P'
+/// InstCombineStoreToCast - Fold store V, (cast P) -> store (cast V), P
 /// when possible.
 static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
   User *CI = cast<User>(SI.getOperand(1));
@@ -8206,8 +8206,9 @@
           if (isa<PointerType>(SIOp0->getType()))
             opcode = Instruction::PtrToInt;
           else if (const IntegerType* SITy = dyn_cast<IntegerType>(CastSrcTy))
-            assert(DITy->getBitWidth() == SITy->getBitWidth() &&
-                   "Illegal store instruction");
+            if (SITy->getBitWidth() != DITy->getBitWidth())
+              return 0; // Don't do this transform on unequal bit widths.
+            // else, BitCast is fine
         }
         if (Constant *C = dyn_cast<Constant>(SIOp0))
           NewCast = ConstantExpr::getCast(opcode, C, CastDstTy);






More information about the llvm-commits mailing list