Align doubles on 8-byte boundaries if possible.
authorChris Lattner <sabre@nondot.org>
Fri, 13 May 2005 23:14:17 +0000 (23:14 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 13 May 2005 23:14:17 +0000 (23:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21993 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index e088845daa8845344041c77406134365a7b623ce..d2cde3489607e817429d2f6ce6814482e949ae1e 100644 (file)
@@ -140,6 +140,15 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli,
         const Type *Ty = AI->getAllocatedType();
         uint64_t TySize = TLI.getTargetData().getTypeSize(Ty);
         unsigned Align = TLI.getTargetData().getTypeAlignment(Ty);
+
+        // If the alignment of the value is smaller than the size of the value,
+        // and if the size of the value is particularly small (<= 8 bytes),
+        // round up to the size of the value for potentially better performance.
+        //
+        // FIXME: This could be made better with a preferred alignment hook in
+        // TargetData.  It serves primarily to 8-byte align doubles for X86.
+        if (Align < TySize && TySize <= 8) Align = TySize;
+
         TySize *= CUI->getValue();   // Get total allocated size.
         StaticAllocaMap[AI] =
           MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align);