1 ; RUN: opt -S -passes='function(scalarizer)' %s | FileCheck %s
3 ; Check that the scalarizer can handle vector GEPs with scalar indices
5 @vec = global <4 x i16*> <i16* null, i16* null, i16* null, i16* null>
7 @ptr = global [4 x i16] [i16 1, i16 2, i16 3, i16 4]
8 @ptrptr = global i16* null
11 define void @test1() {
13 %0 = load <4 x i16*>, <4 x i16*>* @vec
14 %1 = getelementptr i16, <4 x i16*> %0, i16 1
20 ;CHECK: %[[I0:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 0
21 ;CHECK: getelementptr i16, i16* %[[I0]], i16 1
22 ;CHECK: %[[I1:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 1
23 ;CHECK: getelementptr i16, i16* %[[I1]], i16 1
24 ;CHECK: %[[I2:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 2
25 ;CHECK: getelementptr i16, i16* %[[I2]], i16 1
26 ;CHECK: %[[I3:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 3
27 ;CHECK: getelementptr i16, i16* %[[I3]], i16 1
30 define void @test2() {
32 %0 = load <4 x i16*>, <4 x i16*>* @vec
33 %index = load i16, i16* @index
34 %1 = getelementptr i16, <4 x i16*> %0, i16 %index
40 ;CHECK: %0 = load <4 x i16*>, <4 x i16*>* @vec
41 ;CHECK: %[[I0:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 0
42 ;CHECK: %[[I1:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 1
43 ;CHECK: %[[I2:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 2
44 ;CHECK: %[[I3:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 3
45 ;CHECK: %index = load i16, i16* @index
46 ;CHECK: %.splatinsert = insertelement <4 x i16> poison, i16 %index, i32 0
47 ;CHECK: %.splat = shufflevector <4 x i16> %.splatinsert, <4 x i16> poison, <4 x i32> zeroinitializer
48 ;CHECK: %.splat[[I0]] = extractelement <4 x i16> %.splat, i32 0
49 ;CHECK: getelementptr i16, i16* %[[I0]], i16 %.splat[[I0]]
50 ;CHECK: %.splat[[I1]] = extractelement <4 x i16> %.splat, i32 1
51 ;CHECK: getelementptr i16, i16* %[[I1]], i16 %.splat[[I1]]
52 ;CHECK: %.splat[[I2]] = extractelement <4 x i16> %.splat, i32 2
53 ;CHECK: getelementptr i16, i16* %[[I2]], i16 %.splat[[I2]]
54 ;CHECK: %.splat[[I3]] = extractelement <4 x i16> %.splat, i32 3
55 ;CHECK: getelementptr i16, i16* %[[I3]], i16 %.splat[[I3]]
58 ; Check that the scalarizer can handle vector GEPs with scalar pointer
61 define void @test3() {
63 %0 = bitcast [4 x i16]* @ptr to i16*
64 %1 = getelementptr i16, i16* %0, <4 x i16> <i16 0, i16 1, i16 2, i16 3>
70 ;CHECK: %0 = bitcast [4 x i16]* @ptr to i16*
71 ;CHECK: %.splatinsert = insertelement <4 x i16*> poison, i16* %0, i32 0
72 ;CHECK: %.splat = shufflevector <4 x i16*> %.splatinsert, <4 x i16*> poison, <4 x i32> zeroinitializer
73 ;CHECK: %.splat[[I0:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 0
74 ;CHECK: getelementptr i16, i16* %.splat[[I0]], i16 0
75 ;CHECK: %.splat[[I1:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 1
76 ;CHECK: getelementptr i16, i16* %.splat[[I1]], i16 1
77 ;CHECK: %.splat[[I2:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 2
78 ;CHECK: getelementptr i16, i16* %.splat[[I2]], i16 2
79 ;CHECK: %.splat[[I3:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 3
80 ;CHECK: getelementptr i16, i16* %.splat[[I3]], i16 3
82 ; non-constant pointer
83 define void @test4() {
85 %0 = load i16*, i16** @ptrptr
86 %1 = getelementptr i16, i16* %0, <4 x i16> <i16 0, i16 1, i16 2, i16 3>
92 ;CHECK: %0 = load i16*, i16** @ptrptr
93 ;CHECK: %.splatinsert = insertelement <4 x i16*> poison, i16* %0, i32 0
94 ;CHECK: %.splat = shufflevector <4 x i16*> %.splatinsert, <4 x i16*> poison, <4 x i32> zeroinitializer
95 ;CHECK: %.splat[[I0:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 0
96 ;CHECK: getelementptr i16, i16* %.splat[[I0]], i16 0
97 ;CHECK: %.splat[[I1:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 1
98 ;CHECK: getelementptr i16, i16* %.splat[[I1]], i16 1
99 ;CHECK: %.splat[[I2:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 2
100 ;CHECK: getelementptr i16, i16* %.splat[[I2]], i16 2
101 ;CHECK: %.splat[[I3:.i[0-9]*]] = extractelement <4 x i16*> %.splat, i32 3
102 ;CHECK: getelementptr i16, i16* %.splat[[I3]], i16 3
104 ; constant index, inbounds
105 define void @test5() {
107 %0 = load <4 x i16*>, <4 x i16*>* @vec
108 %1 = getelementptr inbounds i16, <4 x i16*> %0, i16 1
114 ;CHECK: %[[I0:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 0
115 ;CHECK: getelementptr inbounds i16, i16* %[[I0]], i16 1
116 ;CHECK: %[[I1:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 1
117 ;CHECK: getelementptr inbounds i16, i16* %[[I1]], i16 1
118 ;CHECK: %[[I2:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 2
119 ;CHECK: getelementptr inbounds i16, i16* %[[I2]], i16 1
120 ;CHECK: %[[I3:.i[0-9]*]] = extractelement <4 x i16*> %0, i32 3
121 ;CHECK: getelementptr inbounds i16, i16* %[[I3]], i16 1