aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
commit90bfc2d10520f9621309436c1c6928a59cd33616 (patch)
tree5ee72d8db996d6cd8b69ddcd164e66354afb98af /lib
parent70ba3d480302187143faf4dc5226a6f3c7b71bc8 (diff)
downloadexternal_llvm-90bfc2d10520f9621309436c1c6928a59cd33616.zip
external_llvm-90bfc2d10520f9621309436c1c6928a59cd33616.tar.gz
external_llvm-90bfc2d10520f9621309436c1c6928a59cd33616.tar.bz2
Pointer arithmetic should be done with the index the same size as the pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index da2c1dc..c111036 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/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);