Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.456 -> 1.457 SelectionDAGISel.cpp updated: 1.342 -> 1.343 --- 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: (+13 -15) LegalizeDAG.cpp | 13 +++++++++---- SelectionDAGISel.cpp | 15 ++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.456 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.457 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.456 Fri Jan 19 15:13:56 2007 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Jan 20 16:35:55 2007 @@ -3029,7 +3029,7 @@ // new ones, as reuse may inhibit scheduling. const Type *Ty = MVT::getTypeForValueType(ExtraVT); unsigned TySize = (unsigned)TLI.getTargetData()->getTypeSize(Ty); - unsigned Align = TLI.getTargetData()->getTypeAlignment(Ty); + unsigned Align = TLI.getTargetData()->getTypeAlignmentPref(Ty); MachineFunction &MF = DAG.getMachineFunction(); int SSFI = MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align); @@ -3937,7 +3937,9 @@ SDOperand SelectionDAGLegalize::CreateStackTemporary(MVT::ValueType VT) { MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo(); unsigned ByteSize = MVT::getSizeInBits(VT)/8; - int FrameIdx = FrameInfo->CreateStackObject(ByteSize, ByteSize); + const Type *Ty = MVT::getTypeForValueType(VT); + unsigned StackAlign = (unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty); + int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign); return DAG.getFrameIndex(FrameIdx, TLI.getPointerTy()); } @@ -4242,9 +4244,12 @@ if (Op0.getValueType() == MVT::i32) { // simple 32-bit [signed|unsigned] integer to float/double expansion - // get the stack frame index of a 8 byte buffer + // get the stack frame index of a 8 byte buffer, pessimistically aligned MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); + const Type *F64Type = MVT::getTypeForValueType(MVT::f64); + unsigned StackAlign = + (unsigned)TLI.getTargetData()->getTypeAlignmentPref(F64Type); + int SSFI = MF.getFrameInfo()->CreateStackObject(8, StackAlign); // get address of 8 byte buffer SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); // word offset constant for Hi/Lo address computation Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.342 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.343 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.342 Thu Jan 11 06:24:14 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sat Jan 20 16:35:55 2007 @@ -244,17 +244,9 @@ const Type *Ty = AI->getAllocatedType(); uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); unsigned Align = - std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty), + std::max((unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty), AI->getAlignment()); - // 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->getZExtValue(); // Get total allocated size. if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects. StaticAllocaMap[AI] = @@ -1729,8 +1721,9 @@ const Type *Ty = I.getAllocatedType(); uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); - unsigned Align = std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty), - I.getAlignment()); + unsigned Align = + std::max((unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty), + I.getAlignment()); SDOperand AllocSize = getValue(I.getArraySize()); MVT::ValueType IntPtr = TLI.getPointerTy(); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits