1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S < %s -passes=load-store-vectorizer | FileCheck %s
3 ; RUN: opt -S < %s -passes='function(load-store-vectorizer)' | FileCheck %s
5 declare void @llvm.sideeffect()
7 ; load-store vectorization across a @llvm.sideeffect.
9 define void @test_sideeffect(ptr %p) {
10 ; CHECK-LABEL: @test_sideeffect(
11 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16
12 ; CHECK-NEXT: [[L01:%.*]] = extractelement <4 x float> [[TMP2]], i32 0
13 ; CHECK-NEXT: [[L12:%.*]] = extractelement <4 x float> [[TMP2]], i32 1
14 ; CHECK-NEXT: [[L23:%.*]] = extractelement <4 x float> [[TMP2]], i32 2
15 ; CHECK-NEXT: [[L34:%.*]] = extractelement <4 x float> [[TMP2]], i32 3
16 ; CHECK-NEXT: call void @llvm.sideeffect()
17 ; CHECK-NEXT: call void @llvm.sideeffect()
18 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x float> poison, float [[L01]], i32 0
19 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP3]], float [[L12]], i32 1
20 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float [[L23]], i32 2
21 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[L34]], i32 3
22 ; CHECK-NEXT: store <4 x float> [[TMP6]], ptr [[P]], align 16
23 ; CHECK-NEXT: ret void
25 %p1 = getelementptr float, ptr %p, i64 1
26 %p2 = getelementptr float, ptr %p, i64 2
27 %p3 = getelementptr float, ptr %p, i64 3
28 %l0 = load float, ptr %p, align 16
29 %l1 = load float, ptr %p1
30 %l2 = load float, ptr %p2
31 call void @llvm.sideeffect()
32 %l3 = load float, ptr %p3
33 store float %l0, ptr %p, align 16
34 call void @llvm.sideeffect()
35 store float %l1, ptr %p1
36 store float %l2, ptr %p2
37 store float %l3, ptr %p3
43 define void @test_inaccessiblememonly_nounwind_willreturn(ptr %p) {
44 ; CHECK-LABEL: @test_inaccessiblememonly_nounwind_willreturn(
45 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16
46 ; CHECK-NEXT: [[L01:%.*]] = extractelement <4 x float> [[TMP2]], i32 0
47 ; CHECK-NEXT: [[L12:%.*]] = extractelement <4 x float> [[TMP2]], i32 1
48 ; CHECK-NEXT: [[L23:%.*]] = extractelement <4 x float> [[TMP2]], i32 2
49 ; CHECK-NEXT: [[L34:%.*]] = extractelement <4 x float> [[TMP2]], i32 3
50 ; CHECK-NEXT: call void @foo() #[[ATTR1:[0-9]+]]
51 ; CHECK-NEXT: call void @foo() #[[ATTR1]]
52 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x float> poison, float [[L01]], i32 0
53 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP3]], float [[L12]], i32 1
54 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float [[L23]], i32 2
55 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[L34]], i32 3
56 ; CHECK-NEXT: store <4 x float> [[TMP6]], ptr [[P]], align 16
57 ; CHECK-NEXT: ret void
59 %p1 = getelementptr float, ptr %p, i64 1
60 %p2 = getelementptr float, ptr %p, i64 2
61 %p3 = getelementptr float, ptr %p, i64 3
62 %l0 = load float, ptr %p, align 16
63 %l1 = load float, ptr %p1
64 %l2 = load float, ptr %p2
65 call void @foo() inaccessiblememonly nounwind willreturn
66 %l3 = load float, ptr %p3
67 store float %l0, ptr %p, align 16
68 call void @foo() inaccessiblememonly nounwind willreturn
69 store float %l1, ptr %p1
70 store float %l2, ptr %p2
71 store float %l3, ptr %p3
75 define void @test_inaccessiblememonly_not_willreturn(ptr %p) {
76 ; CHECK-LABEL: @test_inaccessiblememonly_not_willreturn(
77 ; CHECK-NEXT: [[P1:%.*]] = getelementptr float, ptr [[P:%.*]], i64 1
78 ; CHECK-NEXT: [[P2:%.*]] = getelementptr float, ptr [[P]], i64 2
79 ; CHECK-NEXT: [[P3:%.*]] = getelementptr float, ptr [[P]], i64 3
80 ; CHECK-NEXT: [[L0:%.*]] = load float, ptr [[P]], align 16
81 ; CHECK-NEXT: call void @foo() #[[ATTR2:[0-9]+]]
82 ; CHECK-NEXT: [[L1:%.*]] = load float, ptr [[P1]], align 4
83 ; CHECK-NEXT: [[L2:%.*]] = load float, ptr [[P2]], align 4
84 ; CHECK-NEXT: [[L3:%.*]] = load float, ptr [[P3]], align 4
85 ; CHECK-NEXT: store float [[L0]], ptr [[P]], align 16
86 ; CHECK-NEXT: call void @foo() #[[ATTR2]]
87 ; CHECK-NEXT: store float [[L1]], ptr [[P1]], align 4
88 ; CHECK-NEXT: store float [[L2]], ptr [[P2]], align 4
89 ; CHECK-NEXT: store float [[L3]], ptr [[P3]], align 4
90 ; CHECK-NEXT: ret void
92 %p1 = getelementptr float, ptr %p, i64 1
93 %p2 = getelementptr float, ptr %p, i64 2
94 %p3 = getelementptr float, ptr %p, i64 3
95 %l0 = load float, ptr %p, align 16
96 call void @foo() inaccessiblememonly nounwind
97 %l1 = load float, ptr %p1
98 %l2 = load float, ptr %p2
99 %l3 = load float, ptr %p3
100 store float %l0, ptr %p, align 16
101 call void @foo() inaccessiblememonly nounwind
102 store float %l1, ptr %p1
103 store float %l2, ptr %p2
104 store float %l3, ptr %p3
108 define void @test_inaccessiblememonly_not_nounwind(ptr %p) {
109 ; CHECK-LABEL: @test_inaccessiblememonly_not_nounwind(
110 ; CHECK-NEXT: [[P1:%.*]] = getelementptr float, ptr [[P:%.*]], i64 1
111 ; CHECK-NEXT: [[P2:%.*]] = getelementptr float, ptr [[P]], i64 2
112 ; CHECK-NEXT: [[P3:%.*]] = getelementptr float, ptr [[P]], i64 3
113 ; CHECK-NEXT: [[L0:%.*]] = load float, ptr [[P]], align 16
114 ; CHECK-NEXT: call void @foo() #[[ATTR3:[0-9]+]]
115 ; CHECK-NEXT: [[L1:%.*]] = load float, ptr [[P1]], align 4
116 ; CHECK-NEXT: [[L2:%.*]] = load float, ptr [[P2]], align 4
117 ; CHECK-NEXT: [[L3:%.*]] = load float, ptr [[P3]], align 4
118 ; CHECK-NEXT: store float [[L0]], ptr [[P]], align 16
119 ; CHECK-NEXT: call void @foo() #[[ATTR3]]
120 ; CHECK-NEXT: store float [[L1]], ptr [[P1]], align 4
121 ; CHECK-NEXT: store float [[L2]], ptr [[P2]], align 4
122 ; CHECK-NEXT: store float [[L3]], ptr [[P3]], align 4
123 ; CHECK-NEXT: ret void
125 %p1 = getelementptr float, ptr %p, i64 1
126 %p2 = getelementptr float, ptr %p, i64 2
127 %p3 = getelementptr float, ptr %p, i64 3
128 %l0 = load float, ptr %p, align 16
129 call void @foo() inaccessiblememonly willreturn
130 %l1 = load float, ptr %p1
131 %l2 = load float, ptr %p2
132 %l3 = load float, ptr %p3
133 store float %l0, ptr %p, align 16
134 call void @foo() inaccessiblememonly willreturn
135 store float %l1, ptr %p1
136 store float %l2, ptr %p2
137 store float %l3, ptr %p3