summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/AArch64/tbi.ll
blob: 153bd4e6438d8d3c2153f388404e6ccf932780ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
; RUN: llc -aarch64-use-tbi -mtriple=arm64-apple-ios8.0.0 < %s \
; RUN:     | FileCheck --check-prefix=TBI    --check-prefix=BOTH %s
; RUN: llc -aarch64-use-tbi -mtriple=arm64-apple-ios7.1.0 < %s \
; RUN:     | FileCheck --check-prefix=NO_TBI --check-prefix=BOTH %s

; BOTH-LABEL:ld_and32:
; TBI-NOT: and x
; NO_TBI: and x
define i32 @ld_and32(i64 %p) {
  %and = and i64 %p, 72057594037927935
  %cast = inttoptr i64 %and to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}

; load (r & MASK) + 4
; BOTH-LABEL:ld_and_plus_offset:
; TBI-NOT: and x
; NO_TBI: and x
define i32 @ld_and_plus_offset(i64 %p) {
  %and = and i64 %p, 72057594037927935
  %cast = inttoptr i64 %and to i32*
  %gep = getelementptr i32, i32* %cast, i64 4
  %load = load i32, i32* %gep
  ret i32 %load
}

; load (r & WIDER_MASK)
; BOTH-LABEL:ld_and32_wider:
; TBI-NOT: and x
; NO_TBI: and x
define i32 @ld_and32_wider(i64 %p) {
  %and = and i64 %p, 1152921504606846975
  %cast = inttoptr i64 %and to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}

; BOTH-LABEL:ld_and64:
; TBI-NOT: and x
; NO_TBI: and x
define i64 @ld_and64(i64 %p) {
  %and = and i64 %p, 72057594037927935
  %cast = inttoptr i64 %and to i64*
  %load = load i64, i64* %cast
  ret i64 %load
}

; BOTH-LABEL:st_and32:
; TBI-NOT: and x
; NO_TBI: and x
define void @st_and32(i64 %p, i32 %v) {
  %and = and i64 %p, 72057594037927935
  %cast = inttoptr i64 %and to i32*
  store i32 %v, i32* %cast
  ret void
}

; load (x1 + x2) & MASK
; BOTH-LABEL:ld_ro:
; TBI-NOT: and x
; NO_TBI: and x
define i32 @ld_ro(i64 %a, i64 %b) {
  %p = add i64 %a, %b
  %and = and i64 %p, 72057594037927935
  %cast = inttoptr i64 %and to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}

; load (r1 & MASK) + r2
; BOTH-LABEL:ld_ro2:
; TBI-NOT: and x
; NO_TBI: and x
define i32 @ld_ro2(i64 %a, i64 %b) {
  %and = and i64 %a, 72057594037927935
  %p = add i64 %and, %b
  %cast = inttoptr i64 %p to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}

; load (r1 & MASK) | r2
; BOTH-LABEL:ld_indirect_and:
; TBI-NOT: and x
; NO_TBI: and x
define i32 @ld_indirect_and(i64 %r1, i64 %r2) {
  %and = and i64 %r1, 72057594037927935
  %p = or i64 %and, %r2
  %cast = inttoptr i64 %p to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}

; BOTH-LABEL:ld_and32_narrower:
; BOTH: and x
define i32 @ld_and32_narrower(i64 %p) {
  %and = and i64 %p, 36028797018963967
  %cast = inttoptr i64 %and to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}

; BOTH-LABEL:ld_and8:
; BOTH: and x
define i32 @ld_and8(i64 %base, i8 %off) {
  %off_masked = and i8 %off, 63
  %off_64 = zext i8 %off_masked to i64
  %p = add i64 %base, %off_64
  %cast = inttoptr i64 %p to i32*
  %load = load i32, i32* %cast
  ret i32 %load
}
OpenPOWER on IntegriCloud