summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2007-10-18 08:32:37 +0000
committerBill Wendling <isanbard@gmail.com>2007-10-18 08:32:37 +0000
commit070aca5d2553ea328f5180ee26fb3ddc0dceb066 (patch)
treea00ef003f7e2e62edca7d23198b7d33b03509b8e /llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
parentcb7aca0dcb0e43bf15a94bc57064bd9090601bcb (diff)
downloadbcm5719-llvm-070aca5d2553ea328f5180ee26fb3ddc0dceb066.tar.gz
bcm5719-llvm-070aca5d2553ea328f5180ee26fb3ddc0dceb066.zip
Pointer arithmetic should be done with the index the same size as the pointer.
llvm-svn: 43120
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index da2c1dccb59..c1110368250 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -4134,6 +4134,13 @@ SDOperand SelectionDAGLegalize::ExpandEXTRACT_VECTOR_ELT(SDOperand Op) {
unsigned EltSize = MVT::getSizeInBits(Op.getValueType())/8;
Idx = DAG.getNode(ISD::MUL, Idx.getValueType(), Idx,
DAG.getConstant(EltSize, Idx.getValueType()));
+
+ if (MVT::getSizeInBits(Idx.getValueType()) >
+ MVT::getSizeInBits(TLI.getPointerTy()))
+ Idx = DAG.getNode(ISD::TRUNCATE, TLI.getPointerTy(), StackPtr);
+ else
+ Idx = DAG.getNode(ISD::SIGN_EXTEND, TLI.getPointerTy(), StackPtr);
+
StackPtr = DAG.getNode(ISD::ADD, Idx.getValueType(), Idx, StackPtr);
Op = DAG.getLoad(Op.getValueType(), Ch, StackPtr, NULL, 0);
OpenPOWER on IntegriCloud