Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.450 -> 1.451
---
Log message:

Teach the alignment handling code to look through constant expr casts and GEPs


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

 InstructionCombining.cpp |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.450 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.451
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.450   Mon Mar  6 
14:18:44 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Mar  6 19:28:57 2006
@@ -5285,11 +5285,17 @@
       }
     }
     return Align;
-  } else if (CastInst *CI = dyn_cast<CastInst>(V)) {
+  } else if (isa<CastInst>(V) ||
+             (isa<ConstantExpr>(V) && 
+              cast<ConstantExpr>(V)->getOpcode() == Instruction::Cast)) {
+    User *CI = cast<User>(V);
     if (isa<PointerType>(CI->getOperand(0)->getType()))
       return GetKnownAlignment(CI->getOperand(0), TD);
     return 0;
-  } else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(V)) {
+  } else if (isa<GetElementPtrInst>(V) ||
+             (isa<ConstantExpr>(V) && 
+              cast<ConstantExpr>(V)->getOpcode()==Instruction::GetElementPtr)) 
{
+    User *GEPI = cast<User>(V);
     unsigned BaseAlignment = GetKnownAlignment(GEPI->getOperand(0), TD);
     if (BaseAlignment == 0) return 0;
     
@@ -5311,8 +5317,10 @@
 
     const Type *BasePtrTy = GEPI->getOperand(0)->getType();
     if (TD->getTypeAlignment(cast<PointerType>(BasePtrTy)->getElementType())
-        <= BaseAlignment)
-      return TD->getTypeAlignment(GEPI->getType()->getElementType());
+        <= BaseAlignment) {
+      const Type *GEPTy = GEPI->getType();
+      return TD->getTypeAlignment(cast<PointerType>(GEPTy)->getElementType());
+    }
     return 0;
   }
   return 0;



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to