llvm-mirror/test/Assembler/getelementptr_vec_idx2.ll
Elena Demikhovsky 88c04dfc81 Extended syntax of vector version of getelementptr instruction.
The justification of this change is here: http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-March/082989.html

According to the current GEP syntax, vector GEP requires that each index must be a vector with the same number of elements.

%A = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets

In this implementation I let each index be or vector or scalar. All vector indices must have the same number of elements. The scalar value will mean the splat vector value.

(1) %A = getelementptr i8, i8* %ptr, <4 x i64> %offsets
or
(2) %A = getelementptr i8, <4 x i8*> %ptrs, i64 %offset

In all cases the %A type is <4 x i8*>

In the case (2) we add the same offset to all pointers.

The case (1) covers C[B[i]] case, when we have the same base C and different offsets B[i].

The documentation is updated.

http://reviews.llvm.org/D10496

llvm-svn: 241788
2015-07-09 07:42:48 +00:00

25 lines
696 B
LLVM

; RUN: not llvm-as < %s >/dev/null 2> %t
; RUN: FileCheck %s < %t
; Test that a vector pointer may be used with a scalar index.
; Test that a vector pointer and vector index should have the same vector width
; This code is correct
define <2 x i32*> @test2(<2 x i32*> %a) {
%w = getelementptr i32, <2 x i32*> %a, i32 2
ret <2 x i32*> %w
}
; This code is correct
define <2 x i32*> @test3(i32* %a) {
%w = getelementptr i32, i32* %a, <2 x i32> <i32 2, i32 2>
ret <2 x i32*> %w
}
; CHECK: getelementptr vector index has a wrong number of elements
define <2 x i32> @test1(<2 x i32*> %a) {
%w = getelementptr i32, <2 x i32*> %a, <4 x i32><i32 2, i32 2, i32 2, i32 2>
ret <2 x i32> %w
}