1 ; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -S -o - %s | FileCheck %s
2 ; RUN: opt -mtriple=x86_64-unknown-linux-gnu -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' -S -o - %s | FileCheck %s
4 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
6 ; Vectorized subsets of the load/store chains in the presence of
7 ; interleaved loads/stores
9 ; CHECK-LABEL: @interleave_2L_2S(
10 ; CHECK: load <2 x i32>
12 ; CHECK: store <2 x i32>
14 define void @interleave_2L_2S(i32* noalias %ptr) {
15 %next.gep = getelementptr i32, i32* %ptr, i64 0
16 %next.gep1 = getelementptr i32, i32* %ptr, i64 1
17 %next.gep2 = getelementptr i32, i32* %ptr, i64 2
19 %l1 = load i32, i32* %next.gep1, align 4
20 %l2 = load i32, i32* %next.gep, align 4
21 store i32 0, i32* %next.gep1, align 4
22 store i32 0, i32* %next.gep, align 4
23 %l3 = load i32, i32* %next.gep1, align 4
24 %l4 = load i32, i32* %next.gep2, align 4
29 ; CHECK-LABEL: @interleave_3L_2S_1L(
30 ; CHECK: load <3 x i32>
31 ; CHECK: store <2 x i32>
34 define void @interleave_3L_2S_1L(i32* noalias %ptr) {
35 %next.gep = getelementptr i32, i32* %ptr, i64 0
36 %next.gep1 = getelementptr i32, i32* %ptr, i64 1
37 %next.gep2 = getelementptr i32, i32* %ptr, i64 2
39 %l2 = load i32, i32* %next.gep, align 4
40 %l1 = load i32, i32* %next.gep1, align 4
41 store i32 0, i32* %next.gep1, align 4
42 store i32 0, i32* %next.gep, align 4
43 %l3 = load i32, i32* %next.gep1, align 4
44 %l4 = load i32, i32* %next.gep2, align 4
49 ; CHECK-LABEL: @chain_suffix(
51 ; CHECK: store <2 x i32>
52 ; CHECK: load <2 x i32>
53 define void @chain_suffix(i32* noalias %ptr) {
54 %next.gep = getelementptr i32, i32* %ptr, i64 0
55 %next.gep1 = getelementptr i32, i32* %ptr, i64 1
56 %next.gep2 = getelementptr i32, i32* %ptr, i64 2
58 %l2 = load i32, i32* %next.gep, align 4
59 store i32 0, i32* %next.gep1, align 4
60 store i32 0, i32* %next.gep, align 4
61 %l3 = load i32, i32* %next.gep1, align 4
62 %l4 = load i32, i32* %next.gep2, align 4
68 ; CHECK-LABEL: @chain_prefix_suffix(
69 ; CHECK: load <2 x i32>
70 ; CHECK: store <2 x i32>
71 ; CHECK: load <3 x i32>
72 define void @chain_prefix_suffix(i32* noalias %ptr) {
73 %next.gep = getelementptr i32, i32* %ptr, i64 0
74 %next.gep1 = getelementptr i32, i32* %ptr, i64 1
75 %next.gep2 = getelementptr i32, i32* %ptr, i64 2
76 %next.gep3 = getelementptr i32, i32* %ptr, i64 3
78 %l1 = load i32, i32* %next.gep, align 4
79 %l2 = load i32, i32* %next.gep1, align 4
80 store i32 0, i32* %next.gep1, align 4
81 store i32 0, i32* %next.gep2, align 4
82 %l3 = load i32, i32* %next.gep1, align 4
83 %l4 = load i32, i32* %next.gep2, align 4
84 %l5 = load i32, i32* %next.gep3, align 4
89 ; FIXME: If the chain is too long and TLI says misaligned is not fast,
90 ; then LSV fails to vectorize anything in that chain.
91 ; To reproduce below, add a tmp5 (ptr+4) and load tmp5 into l6 and l7.
93 ; CHECK-LABEL: @interleave_get_longest
94 ; CHECK: load <3 x i32>
96 ; CHECK: store <2 x i32> zeroinitializer
101 define void @interleave_get_longest(i32* noalias %ptr) {
102 %tmp1 = getelementptr i32, i32* %ptr, i64 0
103 %tmp2 = getelementptr i32, i32* %ptr, i64 1
104 %tmp3 = getelementptr i32, i32* %ptr, i64 2
105 %tmp4 = getelementptr i32, i32* %ptr, i64 3
107 %l1 = load i32, i32* %tmp2, align 4
108 %l2 = load i32, i32* %tmp1, align 4
109 store i32 0, i32* %tmp2, align 4
110 store i32 0, i32* %tmp1, align 4
111 %l3 = load i32, i32* %tmp2, align 4
112 %l4 = load i32, i32* %tmp3, align 4
113 %l5 = load i32, i32* %tmp4, align 4
114 %l6 = load i32, i32* %tmp4, align 4
115 %l7 = load i32, i32* %tmp4, align 4