1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-unknown-unknown -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
10 ; CHECK-LABEL: name: flip_eq
12 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
13 ; CHECK: %copy:gpr64all = COPY $x0
14 ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
15 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
16 ; CHECK: TBNZW [[COPY1]], 3, %bb.1
21 successors: %bb.0, %bb.1
23 %copy:gpr(s64) = COPY $x0
26 %bit:gpr(s64) = G_CONSTANT i64 8
27 %zero:gpr(s64) = G_CONSTANT i64 0
29 ; 8 has the third bit set.
30 %fold_cst:gpr(s64) = G_CONSTANT i64 8
32 ; This only has the third bit set if %copy does not. So, to walk through
33 ; this, we want to use a TBNZW on %copy.
34 %fold_me:gpr(s64) = G_XOR %copy, %fold_cst
36 %and:gpr(s64) = G_AND %fold_me, %bit
37 %cmp:gpr(s32) = G_ICMP intpred(eq), %and(s64), %zero
38 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
39 G_BRCOND %cmp_trunc(s1), %bb.1
50 ; CHECK-LABEL: name: flip_ne
52 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
53 ; CHECK: %copy:gpr64all = COPY $x0
54 ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
55 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
56 ; CHECK: TBZW [[COPY1]], 3, %bb.1
61 successors: %bb.0, %bb.1
64 ; Same as eq case, but we should get a TBZW instead.
66 %copy:gpr(s64) = COPY $x0
67 %bit:gpr(s64) = G_CONSTANT i64 8
68 %zero:gpr(s64) = G_CONSTANT i64 0
69 %fold_cst:gpr(s64) = G_CONSTANT i64 8
70 %fold_me:gpr(s64) = G_XOR %copy, %fold_cst
71 %and:gpr(s64) = G_AND %fold_me, %bit
72 %cmp:gpr(s32) = G_ICMP intpred(ne), %and(s64), %zero
73 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
74 G_BRCOND %cmp_trunc(s1), %bb.1
85 ; CHECK-LABEL: name: dont_flip_eq
87 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
88 ; CHECK: %copy:gpr64all = COPY $x0
89 ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
90 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
91 ; CHECK: TBZW [[COPY1]], 3, %bb.1
96 successors: %bb.0, %bb.1
98 %copy:gpr(s64) = COPY $x0
101 %bit:gpr(s64) = G_CONSTANT i64 8
102 %zero:gpr(s64) = G_CONSTANT i64 0
104 ; 7 does not have the third bit set.
105 %fold_cst:gpr(s64) = G_CONSTANT i64 7
107 ; This only has the third bit set if %copy does. So, to walk through this,
108 ; we should have a TBZW on %copy.
109 %fold_me:gpr(s64) = G_XOR %fold_cst, %copy
111 %and:gpr(s64) = G_AND %fold_me, %bit
112 %cmp:gpr(s32) = G_ICMP intpred(eq), %and(s64), %zero
113 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
114 G_BRCOND %cmp_trunc(s1), %bb.1
123 regBankSelected: true
125 ; CHECK-LABEL: name: dont_flip_ne
127 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
128 ; CHECK: %copy:gpr64all = COPY $x0
129 ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
130 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
131 ; CHECK: TBNZW [[COPY1]], 3, %bb.1
134 ; CHECK: RET_ReallyLR
136 successors: %bb.0, %bb.1
139 ; Same as eq case, but we should get a TBNZW instead.
141 %copy:gpr(s64) = COPY $x0
142 %bit:gpr(s64) = G_CONSTANT i64 8
143 %zero:gpr(s64) = G_CONSTANT i64 0
144 %fold_cst:gpr(s64) = G_CONSTANT i64 7
145 %fold_me:gpr(s64) = G_XOR %fold_cst, %copy
146 %and:gpr(s64) = G_AND %fold_me, %bit
147 %cmp:gpr(s32) = G_ICMP intpred(ne), %and(s64), %zero
148 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
149 G_BRCOND %cmp_trunc(s1), %bb.1
158 regBankSelected: true
160 ; CHECK-LABEL: name: xor_chain
162 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
163 ; CHECK: %copy:gpr64all = COPY $x0
164 ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %copy.sub_32
165 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]]
166 ; CHECK: TBZW [[COPY1]], 3, %bb.1
169 ; CHECK: RET_ReallyLR
171 successors: %bb.0, %bb.1
173 %copy:gpr(s64) = COPY $x0
174 %bit:gpr(s64) = G_CONSTANT i64 8
175 %zero:gpr(s64) = G_CONSTANT i64 0
176 %fold_cst:gpr(s64) = G_CONSTANT i64 8
178 ; The G_XORs cancel each other out, so we should get a TBZW.
179 %xor1:gpr(s64) = G_XOR %copy, %fold_cst
180 %xor2:gpr(s64) = G_XOR %xor1, %fold_cst
182 %and:gpr(s64) = G_AND %xor2, %bit
183 %cmp:gpr(s32) = G_ICMP intpred(eq), %and(s64), %zero
184 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
185 G_BRCOND %cmp_trunc(s1), %bb.1