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

Chris Lattner sabre at nondot.org
Sat Jan 20 14:36:29 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

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

Teach TargetData to handle 'preferred' alignment for each target, and use 
these alignment amounts to align scalars when we can.  Patch by Scott Michel!



---
Diffs of the changes:  (+15 -9)

 InstructionCombining.cpp |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.605 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.606
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.605	Fri Jan 19 15:20:31 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Sat Jan 20 16:35:55 2007
@@ -5779,8 +5779,8 @@
   const Type *CastElTy = PTy->getElementType();
   if (!AllocElTy->isSized() || !CastElTy->isSized()) return 0;
 
-  unsigned AllocElTyAlign = TD->getTypeAlignment(AllocElTy);
-  unsigned CastElTyAlign = TD->getTypeAlignment(CastElTy);
+  unsigned AllocElTyAlign = TD->getTypeAlignmentABI(AllocElTy);
+  unsigned CastElTyAlign = TD->getTypeAlignmentABI(CastElTy);
   if (CastElTyAlign < AllocElTyAlign) return 0;
 
   // If the allocation has multiple uses, only promote it if we are strictly
@@ -6878,18 +6878,22 @@
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
     unsigned Align = GV->getAlignment();
     if (Align == 0 && TD) 
-      Align = TD->getTypeAlignment(GV->getType()->getElementType());
+      Align = TD->getTypeAlignmentPref(GV->getType()->getElementType());
     return Align;
   } else if (AllocationInst *AI = dyn_cast<AllocationInst>(V)) {
     unsigned Align = AI->getAlignment();
     if (Align == 0 && TD) {
       if (isa<AllocaInst>(AI))
-        Align = TD->getTypeAlignment(AI->getType()->getElementType());
+        Align = TD->getTypeAlignmentPref(AI->getType()->getElementType());
       else if (isa<MallocInst>(AI)) {
         // Malloc returns maximally aligned memory.
-        Align = TD->getTypeAlignment(AI->getType()->getElementType());
-        Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::DoubleTy));
-        Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::Int64Ty));
+        Align = TD->getTypeAlignmentABI(AI->getType()->getElementType());
+        Align =
+          std::max(Align,
+                   (unsigned)TD->getTypeAlignmentABI(Type::DoubleTy));
+        Align =
+          std::max(Align,
+                   (unsigned)TD->getTypeAlignmentABI(Type::Int64Ty));
       }
     }
     return Align;
@@ -6924,10 +6928,12 @@
     if (!TD) return 0;
 
     const Type *BasePtrTy = GEPI->getOperand(0)->getType();
-    if (TD->getTypeAlignment(cast<PointerType>(BasePtrTy)->getElementType())
+    const PointerType *PtrTy = cast<PointerType>(BasePtrTy);
+    if (TD->getTypeAlignmentABI(PtrTy->getElementType())
         <= BaseAlignment) {
       const Type *GEPTy = GEPI->getType();
-      return TD->getTypeAlignment(cast<PointerType>(GEPTy)->getElementType());
+      const PointerType *GEPPtrTy = cast<PointerType>(GEPTy);
+      return TD->getTypeAlignmentABI(GEPPtrTy->getElementType());
     }
     return 0;
   }






More information about the llvm-commits mailing list