xref: /llvm-project/llvm/test/CodeGen/Hexagon/memops-stack.ll (revision 2208c97c1bec2512d4e47b6223db6d95a7037956)
1; RUN: llc -mtriple=hexagon < %s | FileCheck %s
2
3target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
4target triple = "hexagon"
5
6; CHECK-LABEL: test0
7; CHECK: memw(r29+#{{[0-9]+}}) += #1
8define void @test0() #0 {
9entry:
10  %x = alloca i32, align 4
11  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
12  call void @foo(ptr nonnull %x) #3
13  %0 = load i32, ptr %x, align 4, !tbaa !1
14  %inc = add nsw i32 %0, 1
15  store i32 %inc, ptr %x, align 4, !tbaa !1
16  call void @foo(ptr nonnull %x) #3
17  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
18  ret void
19}
20
21; CHECK-LABEL: test1
22; CHECK: memw(r29+#{{[0-9]+}}) -= #1
23define void @test1() #0 {
24entry:
25  %x = alloca i32, align 4
26  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
27  call void @foo(ptr nonnull %x) #3
28  %0 = load i32, ptr %x, align 4, !tbaa !1
29  %inc = sub nsw i32 %0, 1
30  store i32 %inc, ptr %x, align 4, !tbaa !1
31  call void @foo(ptr nonnull %x) #3
32  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
33  ret void
34}
35
36; CHECK-LABEL: test2
37; CHECK: memw(r29+#{{[0-9]+}}) = setbit(#0)
38define void @test2() #0 {
39entry:
40  %x = alloca i32, align 4
41  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
42  call void @foo(ptr nonnull %x) #3
43  %0 = load i32, ptr %x, align 4, !tbaa !1
44  %inc = or i32 %0, 1
45  store i32 %inc, ptr %x, align 4, !tbaa !1
46  call void @foo(ptr nonnull %x) #3
47  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
48  ret void
49}
50
51; CHECK-LABEL: test3
52; CHECK: memw(r29+#{{[0-9]+}}) = clrbit(#0)
53define void @test3() #0 {
54entry:
55  %x = alloca i32, align 4
56  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
57  call void @foo(ptr nonnull %x) #3
58  %0 = load i32, ptr %x, align 4, !tbaa !1
59  %inc = and i32 %0, -2
60  store i32 %inc, ptr %x, align 4, !tbaa !1
61  call void @foo(ptr nonnull %x) #3
62  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
63  ret void
64}
65
66; CHECK-LABEL: test4
67; CHECK: memw(r29+#{{[0-9]+}}) += r
68define void @test4(i32 %a) #0 {
69entry:
70  %x = alloca i32, align 4
71  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
72  call void @foo(ptr nonnull %x) #3
73  %0 = load i32, ptr %x, align 4, !tbaa !1
74  %inc = add nsw i32 %0, %a
75  store i32 %inc, ptr %x, align 4, !tbaa !1
76  call void @foo(ptr nonnull %x) #3
77  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
78  ret void
79}
80
81; CHECK-LABEL: test5
82; CHECK: memw(r29+#{{[0-9]+}}) -= r
83define void @test5(i32 %a) #0 {
84entry:
85  %x = alloca i32, align 4
86  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
87  call void @foo(ptr nonnull %x) #3
88  %0 = load i32, ptr %x, align 4, !tbaa !1
89  %inc = sub nsw i32 %0, %a
90  store i32 %inc, ptr %x, align 4, !tbaa !1
91  call void @foo(ptr nonnull %x) #3
92  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
93  ret void
94}
95
96; CHECK-LABEL: test6
97; CHECK: memw(r29+#{{[0-9]+}}) |= r
98define void @test6(i32 %a) #0 {
99entry:
100  %x = alloca i32, align 4
101  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
102  call void @foo(ptr nonnull %x) #3
103  %0 = load i32, ptr %x, align 4, !tbaa !1
104  %inc = or i32 %0, %a
105  store i32 %inc, ptr %x, align 4, !tbaa !1
106  call void @foo(ptr nonnull %x) #3
107  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
108  ret void
109}
110
111; CHECK-LABEL: test7
112; CHECK: memw(r29+#{{[0-9]+}}) &= r
113define void @test7(i32 %a) #0 {
114entry:
115  %x = alloca i32, align 4
116  call void @llvm.lifetime.start.p0(i64 4, ptr %x) #3
117  call void @foo(ptr nonnull %x) #3
118  %0 = load i32, ptr %x, align 4, !tbaa !1
119  %inc = and i32 %0, %a
120  store i32 %inc, ptr %x, align 4, !tbaa !1
121  call void @foo(ptr nonnull %x) #3
122  call void @llvm.lifetime.end.p0(i64 4, ptr %x) #3
123  ret void
124}
125
126
127declare void @foo(ptr) #2
128declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1
129declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
130
131attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" "unsafe-fp-math"="false" "use-soft-float"="false" }
132attributes #1 = { argmemonly nounwind }
133attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" "unsafe-fp-math"="false" "use-soft-float"="false" }
134attributes #3 = { nounwind }
135
136!1 = !{!2, !2, i64 0}
137!2 = !{!"int", !3, i64 0}
138!3 = !{!"omnipotent char", !4, i64 0}
139!4 = !{!"Simple C/C++ TBAA"}
140