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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
; RUN: llc -aarch64-atomic-cfg-tidy=0 -verify-machineinstrs -mtriple=aarch64-apple-darwin < %s | FileCheck %s
; RUN: llc -fast-isel -fast-isel-abort -aarch64-atomic-cfg-tidy=0 -verify-machineinstrs -mtriple=aarch64-apple-darwin < %s | FileCheck %s
define i32 @icmp_eq_i8(i8 zeroext %a) {
; CHECK-LABEL: icmp_eq_i8
; CHECK: tbz {{w[0-9]+}}, #0, {{LBB.+_2}}
%1 = and i8 %a, 1
%2 = icmp eq i8 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_eq_i16(i16 zeroext %a) {
; CHECK-LABEL: icmp_eq_i16
; CHECK: tbz w0, #1, {{LBB.+_2}}
%1 = and i16 %a, 2
%2 = icmp eq i16 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_eq_i32(i32 %a) {
; CHECK-LABEL: icmp_eq_i32
; CHECK: tbz w0, #2, {{LBB.+_2}}
%1 = and i32 %a, 4
%2 = icmp eq i32 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_eq_i64_1(i64 %a) {
; CHECK-LABEL: icmp_eq_i64_1
; CHECK: tbz w0, #3, {{LBB.+_2}}
%1 = and i64 %a, 8
%2 = icmp eq i64 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_eq_i64_2(i64 %a) {
; CHECK-LABEL: icmp_eq_i64_2
; CHECK: tbz x0, #32, {{LBB.+_2}}
%1 = and i64 %a, 4294967296
%2 = icmp eq i64 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_ne_i8(i8 zeroext %a) {
; CHECK-LABEL: icmp_ne_i8
; CHECK: tbnz w0, #0, {{LBB.+_2}}
%1 = and i8 %a, 1
%2 = icmp ne i8 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_ne_i16(i16 zeroext %a) {
; CHECK-LABEL: icmp_ne_i16
; CHECK: tbnz w0, #1, {{LBB.+_2}}
%1 = and i16 %a, 2
%2 = icmp ne i16 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_ne_i32(i32 %a) {
; CHECK-LABEL: icmp_ne_i32
; CHECK: tbnz w0, #2, {{LBB.+_2}}
%1 = and i32 %a, 4
%2 = icmp ne i32 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_ne_i64_1(i64 %a) {
; CHECK-LABEL: icmp_ne_i64_1
; CHECK: tbnz w0, #3, {{LBB.+_2}}
%1 = and i64 %a, 8
%2 = icmp ne i64 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
define i32 @icmp_ne_i64_2(i64 %a) {
; CHECK-LABEL: icmp_ne_i64_2
; CHECK: tbnz x0, #32, {{LBB.+_2}}
%1 = and i64 %a, 4294967296
%2 = icmp ne i64 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
; Test that we don't fold the 'and' instruction into the compare.
define i32 @icmp_eq_and_i32(i32 %a, i1 %c) {
; CHECK-LABEL: icmp_eq_and_i32
; CHECK: and [[REG:w[0-9]+]], w0, #0x4
; CHECK-NEXT: cbz [[REG]], {{LBB.+_3}}
%1 = and i32 %a, 4
br i1 %c, label %bb0, label %bb2
bb0:
%2 = icmp eq i32 %1, 0
br i1 %2, label %bb1, label %bb2, !prof !0
bb1:
ret i32 1
bb2:
ret i32 0
}
!0 = metadata !{metadata !"branch_weights", i32 0, i32 2147483647}
!1 = metadata !{metadata !"branch_weights", i32 2147483647, i32 0}
|