1; RUN: llc -mtriple=thumb-eabi -mattr=-thumb2 %s -o - | FileCheck %s -check-prefix CHECK-T1
2; RUN: llc -mtriple=thumb-eabi -mattr=+v7 %s -o - | FileCheck %s -check-prefix=THUMB2
3; RUN: llc -mtriple=arm-eabi -mattr=+v7 %s -o - | FileCheck %s -check-prefix=ARM
4; RUN: llc -mtriple=arm-eabi -mcpu=cortex-a9 %s -o - | FileCheck %s -check-prefix=ARM-MP
5; rdar://8601536
6
7; CHECK-T1-NOT: pld
8
9define void @t1(i8* %ptr) nounwind  {
10entry:
11; ARM-LABEL: t1:
12; ARM-NOT: pldw [r0]
13; ARM: pld [r0]
14
15; ARM-MP-LABEL: t1:
16; ARM-MP: pldw [r0]
17; ARM-MP: pld [r0]
18
19; THUMB2-LABEL: t1:
20; THUMB2-NOT: pldw [r0]
21; THUMB2: pld [r0]
22  tail call void @llvm.prefetch( i8* %ptr, i32 1, i32 3, i32 1 )
23  tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 3, i32 1 )
24  ret void
25}
26
27define void @t2(i8* %ptr) nounwind  {
28entry:
29; ARM-LABEL: t2:
30; ARM: pld [r0, #1023]
31
32; THUMB2-LABEL: t2:
33; THUMB2: pld [r0, #1023]
34  %tmp = getelementptr i8, i8* %ptr, i32 1023
35  tail call void @llvm.prefetch( i8* %tmp, i32 0, i32 3, i32 1 )
36  ret void
37}
38
39define void @t3(i32 %base, i32 %offset) nounwind  {
40entry:
41; ARM-LABEL: t3:
42; ARM: pld [r0, r1, lsr #2]
43
44; THUMB2-LABEL: t3:
45; THUMB2: lsrs r1, r1, #2
46; THUMB2: pld [r0, r1]
47  %tmp1 = lshr i32 %offset, 2
48  %tmp2 = add i32 %base, %tmp1
49  %tmp3 = inttoptr i32 %tmp2 to i8*
50  tail call void @llvm.prefetch( i8* %tmp3, i32 0, i32 3, i32 1 )
51  ret void
52}
53
54define void @t4(i32 %base, i32 %offset) nounwind  {
55entry:
56; ARM-LABEL: t4:
57; ARM: pld [r0, r1, lsl #2]
58
59; THUMB2-LABEL: t4:
60; THUMB2: pld [r0, r1, lsl #2]
61  %tmp1 = shl i32 %offset, 2
62  %tmp2 = add i32 %base, %tmp1
63  %tmp3 = inttoptr i32 %tmp2 to i8*
64  tail call void @llvm.prefetch( i8* %tmp3, i32 0, i32 3, i32 1 )
65  ret void
66}
67
68declare void @llvm.prefetch(i8*, i32, i32, i32) nounwind
69
70define void @t5(i8* %ptr) nounwind  {
71entry:
72; ARM-LABEL: t5:
73; ARM: pli [r0]
74
75; THUMB2-LABEL: t5:
76; THUMB2: pli [r0]
77  tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 3, i32 0 )
78  ret void
79}
80
81define void @t6() {
82entry:
83;ARM-LABEL: t6:
84;ARM: pld [sp]
85;ARM: pld [sp, #50]
86
87;THUMB2-LABEL: t6:
88;THUMB2: pld [sp]
89;THUMB2: pld [sp, #50]
90
91%red = alloca [100 x i8], align 1
92%0 = getelementptr inbounds [100 x i8], [100 x i8]* %red, i32 0, i32 0
93%1 = getelementptr inbounds [100 x i8], [100 x i8]* %red, i32 0, i32 50
94call void @llvm.prefetch(i8* %0, i32 0, i32 3, i32 1)
95call void @llvm.prefetch(i8* %1, i32 0, i32 3, i32 1)
96ret void
97}
98