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