Fix the alignment of loads from constant pool entries when the
authorDan Gohman <gohman@apple.com>
Mon, 22 Sep 2008 22:40:08 +0000 (22:40 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 22 Sep 2008 22:40:08 +0000 (22:40 +0000)
load address has an offset from the base of the constant pool
entry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56479 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

index 0d27e6620199dc634709562d8ff65847d14a1c8a..ae6951fd271838203b5990c9d2cf81547ee3634e 100644 (file)
@@ -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,
index 7fea9c8a8c35d7e546d05a7c72ee73ca7f5a7310..2e5f8bea80b663a369c8dc4edffbc7cda8f26edb 100644 (file)
@@ -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);
   }