diff options
author | Dan Gohman <gohman@apple.com> | 2008-09-22 22:40:08 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-09-22 22:40:08 +0000 |
commit | e2947e1e077205241c94a5bffbccba5b64cf05bf (patch) | |
tree | 33dc9c47812405614d5fbf32fa0aa8b64ebf2b35 /llvm/lib/CodeGen | |
parent | 8f8466dc426263e6f2c257772a98670c2dca50b1 (diff) | |
download | bcm5719-llvm-e2947e1e077205241c94a5bffbccba5b64cf05bf.tar.gz bcm5719-llvm-e2947e1e077205241c94a5bffbccba5b64cf05bf.zip |
Fix the alignment of loads from constant pool entries when the
load address has an offset from the base of the constant pool
entry.
llvm-svn: 56479
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 0d27e662019..ae6951fd271 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -5438,6 +5438,7 @@ ExpandIntToFP(bool isSigned, MVT DestTy, SDValue Source) { SDValue CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy()); unsigned Alignment = 1 << cast<ConstantPoolSDNode>(CPIdx)->getAlignment(); CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset); + Alignment = std::min(Alignment, 4u); SDValue FudgeInReg; if (DestTy == MVT::f32) FudgeInReg = DAG.getLoad(MVT::f32, DAG.getEntryNode(), CPIdx, @@ -5589,6 +5590,7 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(bool isSigned, SDValue CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy()); unsigned Alignment = 1 << cast<ConstantPoolSDNode>(CPIdx)->getAlignment(); CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset); + Alignment = std::min(Alignment, 4u); SDValue FudgeInReg; if (DestVT == MVT::f32) FudgeInReg = DAG.getLoad(MVT::f32, DAG.getEntryNode(), CPIdx, diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 7fea9c8a8c3..2e5f8bea80b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -2042,12 +2042,16 @@ SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { if (TLI.isBigEndian()) std::swap(Zero, Four); SDValue Offset = DAG.getNode(ISD::SELECT, Zero.getValueType(), SignSet, Zero, Four); + unsigned Alignment = + 1 << cast<ConstantPoolSDNode>(FudgePtr)->getAlignment(); FudgePtr = DAG.getNode(ISD::ADD, TLI.getPointerTy(), FudgePtr, Offset); + Alignment = std::min(Alignment, 4u); // Load the value out, extending it from f32 to the destination float type. // FIXME: Avoid the extend by constructing the right constant pool? SDValue Fudge = DAG.getExtLoad(ISD::EXTLOAD, DstVT, DAG.getEntryNode(), - FudgePtr, NULL, 0, MVT::f32); + FudgePtr, NULL, 0, MVT::f32, + false, Alignment); return DAG.getNode(ISD::FADD, DstVT, SignedConv, Fudge); } |