From: Duncan Sands Date: Tue, 13 Nov 2012 13:01:58 +0000 (+0000) Subject: Codegen support for arbitrary vector getelementptrs. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8d3caf65a7244c11b5ec2d41fa5033c3e319f55;p=platform%2Fupstream%2Fllvm.git Codegen support for arbitrary vector getelementptrs. llvm-svn: 167830 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 3fbf7c2..0af7b9a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3137,12 +3137,12 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) { OI != E; ++OI) { const Value *Idx = *OI; if (StructType *StTy = dyn_cast(Ty)) { - unsigned Field = cast(Idx)->getZExtValue(); + unsigned Field = cast(Idx)->getUniqueInteger().getZExtValue(); if (Field) { // N = N + Offset uint64_t Offset = TD->getStructLayout(StTy)->getElementOffset(Field); N = DAG.getNode(ISD::ADD, getCurDebugLoc(), N.getValueType(), N, - DAG.getIntPtrConstant(Offset)); + DAG.getConstant(Offset, N.getValueType())); } Ty = StTy->getElementType(Field); @@ -3187,7 +3187,7 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) { N.getValueType(), IdxN, DAG.getConstant(Amt, IdxN.getValueType())); } else { - SDValue Scale = DAG.getConstant(ElementSize, TLI.getPointerTy()); + SDValue Scale = DAG.getConstant(ElementSize, IdxN.getValueType()); IdxN = DAG.getNode(ISD::MUL, getCurDebugLoc(), N.getValueType(), IdxN, Scale); } diff --git a/llvm/test/CodeGen/Generic/vector.ll b/llvm/test/CodeGen/Generic/vector.ll index a0f9a02..84814a1 100644 --- a/llvm/test/CodeGen/Generic/vector.ll +++ b/llvm/test/CodeGen/Generic/vector.ll @@ -152,3 +152,8 @@ define void @splat_i4(%i4* %P, %i4* %Q, i32 %X) { store %i4 %R, %i4* %P ret void } + +define <2 x i32*> @vector_gep(<2 x [3 x {i32, i32}]*> %a) { + %w = getelementptr <2 x [3 x {i32, i32}]*> %a, <2 x i32> , <2 x i32> , <2 x i32> + ret <2 x i32*> %w +}