1; RUN: opt -S -basicaa -slp-vectorizer -dce < %s | FileCheck %s
2target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
3target triple = "arm64-apple-ios5.0.0"
4
5; CHECK-LABEL: @foo
6define void @foo(float* noalias %a, float* noalias %b, float* noalias %c) {
7entry:
8; Check that we don't lose !nontemporal hint when vectorizing loads.
9; CHECK: %{{[0-9]*}} = load <4 x float>, <4 x float>* %{{[0-9]+}}, align 4, !nontemporal !0
10  %b1 = load float, float* %b, align 4, !nontemporal !0
11  %arrayidx.1 = getelementptr inbounds float, float* %b, i64 1
12  %b2 = load float, float* %arrayidx.1, align 4, !nontemporal !0
13  %arrayidx.2 = getelementptr inbounds float, float* %b, i64 2
14  %b3 = load float, float* %arrayidx.2, align 4, !nontemporal !0
15  %arrayidx.3 = getelementptr inbounds float, float* %b, i64 3
16  %b4 = load float, float* %arrayidx.3, align 4, !nontemporal !0
17
18; Check that we don't introduce !nontemporal hint when the original scalar loads didn't have it.
19; CHECK: %{{[0-9]*}} = load <4 x float>, <4 x float>* %{{[0-9]+}}, align 4{{$}}
20  %c1 = load float, float* %c, align 4
21  %arrayidx2.1 = getelementptr inbounds float, float* %c, i64 1
22  %c2 = load float, float* %arrayidx2.1, align 4
23  %arrayidx2.2 = getelementptr inbounds float, float* %c, i64 2
24  %c3 = load float, float* %arrayidx2.2, align 4
25  %arrayidx2.3 = getelementptr inbounds float, float* %c, i64 3
26  %c4 = load float, float* %arrayidx2.3, align 4
27
28  %a1 = fadd float %b1, %c1
29  %a2 = fadd float %b2, %c2
30  %a3 = fadd float %b3, %c3
31  %a4 = fadd float %b4, %c4
32
33; Check that we don't lose !nontemporal hint when vectorizing stores.
34; CHECK: store <4 x float> %{{[0-9]+}}, <4 x float>* %{{[0-9]+}}, align 4, !nontemporal !0
35  store float %a1, float* %a, align 4, !nontemporal !0
36  %arrayidx3.1 = getelementptr inbounds float, float* %a, i64 1
37  store float %a2, float* %arrayidx3.1, align 4, !nontemporal !0
38  %arrayidx3.2 = getelementptr inbounds float, float* %a, i64 2
39  store float %a3, float* %arrayidx3.2, align 4, !nontemporal !0
40  %arrayidx3.3 = getelementptr inbounds float, float* %a, i64 3
41  store float %a4, float* %arrayidx3.3, align 4, !nontemporal !0
42
43; CHECK: ret void
44  ret void
45}
46
47; CHECK-LABEL: @foo2
48define void @foo2(float* noalias %a, float* noalias %b) {
49entry:
50; Check that we don't mark vector load with !nontemporal attribute if some of
51; the original scalar loads don't have it.
52; CHECK: %{{[0-9]*}} = load <4 x float>, <4 x float>* %{{[0-9]+}}, align 4{{$}}
53  %b1 = load float, float* %b, align 4, !nontemporal !0
54  %arrayidx.1 = getelementptr inbounds float, float* %b, i64 1
55  %b2 = load float, float* %arrayidx.1, align 4
56  %arrayidx.2 = getelementptr inbounds float, float* %b, i64 2
57  %b3 = load float, float* %arrayidx.2, align 4
58  %arrayidx.3 = getelementptr inbounds float, float* %b, i64 3
59  %b4 = load float, float* %arrayidx.3, align 4, !nontemporal !0
60
61; Check that we don't mark vector store with !nontemporal attribute if some of
62; the original scalar stores don't have it.
63; CHECK: store <4 x float> %{{[0-9]+}}, <4 x float>* %{{[0-9]+}}, align 4{{$}}
64  store float %b1, float* %a, align 4, !nontemporal !0
65  %arrayidx3.1 = getelementptr inbounds float, float* %a, i64 1
66  store float %b2, float* %arrayidx3.1, align 4
67  %arrayidx3.2 = getelementptr inbounds float, float* %a, i64 2
68  store float %b3, float* %arrayidx3.2, align 4
69  %arrayidx3.3 = getelementptr inbounds float, float* %a, i64 3
70  store float %b4, float* %arrayidx3.3, align 4, !nontemporal !0
71
72; CHECK: ret void
73  ret void
74}
75
76!0 = !{i32 1}
77