[llvm-commits] [llvm] r69574 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Sanjiv Gupta sanjiv.gupta at microchip.com
Sun Apr 19 23:05:54 PDT 2009


Author: sgupta
Date: Mon Apr 20 01:05:54 2009
New Revision: 69574

URL: http://llvm.org/viewvc/llvm-project?rev=69574&view=rev
Log:
Before trying to introduce/eliminate cast/ext/trunc to make indices type as
pointer type, make sure that the pointer size is a valid sequential index type.

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=69574&r1=69573&r2=69574&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Apr 20 01:05:54 2009
@@ -10695,7 +10695,12 @@
   gep_type_iterator GTI = gep_type_begin(GEP);
   for (User::op_iterator i = GEP.op_begin() + 1, e = GEP.op_end();
        i != e; ++i, ++GTI) {
-    if (isa<SequentialType>(*GTI)) {
+    // Before trying to eliminate/introduce cast/ext/trunc to make
+    // indices as pointer types, make sure that the pointer size
+    // makes a valid sequential index.
+    const SequentialType *ST = dyn_cast<SequentialType>(*GTI);
+    Value *PtrTypeVal = Constant::getNullValue(TD->getIntPtrType());
+    if (ST && ST->indexValid(PtrTypeVal)) {
       if (CastInst *CI = dyn_cast<CastInst>(*i)) {
         if (CI->getOpcode() == Instruction::ZExt ||
             CI->getOpcode() == Instruction::SExt) {





More information about the llvm-commits mailing list