• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3...
4---
5name:            flip_eq
6alignment:       4
7legalized:       true
8regBankSelected: true
9body:             |
10  ; CHECK-LABEL: name: flip_eq
11  ; CHECK: bb.0:
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
17  ; CHECK:   B %bb.0
18  ; CHECK: bb.1:
19  ; CHECK:   RET_ReallyLR
20  bb.0:
21    successors: %bb.0, %bb.1
22    liveins: $x0
23    %copy:gpr(s64) = COPY $x0
24
25    ; Check bit 3.
26    %bit:gpr(s64) = G_CONSTANT i64 8
27    %zero:gpr(s64) = G_CONSTANT i64 0
28
29    ; 8 has the third bit set.
30    %fold_cst:gpr(s64) = G_CONSTANT i64 8
31
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
35
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
40    G_BR %bb.0
41  bb.1:
42    RET_ReallyLR
43...
44---
45name:            flip_ne
46alignment:       4
47legalized:       true
48regBankSelected: true
49body:             |
50  ; CHECK-LABEL: name: flip_ne
51  ; CHECK: bb.0:
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
57  ; CHECK:   B %bb.0
58  ; CHECK: bb.1:
59  ; CHECK:   RET_ReallyLR
60  bb.0:
61    successors: %bb.0, %bb.1
62    liveins: $x0
63
64    ; Same as eq case, but we should get a TBZW instead.
65
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
75    G_BR %bb.0
76  bb.1:
77    RET_ReallyLR
78...
79---
80name:            dont_flip_eq
81alignment:       4
82legalized:       true
83regBankSelected: true
84body:             |
85  ; CHECK-LABEL: name: dont_flip_eq
86  ; CHECK: bb.0:
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
92  ; CHECK:   B %bb.0
93  ; CHECK: bb.1:
94  ; CHECK:   RET_ReallyLR
95  bb.0:
96    successors: %bb.0, %bb.1
97    liveins: $x0
98    %copy:gpr(s64) = COPY $x0
99
100    ; Check bit 3.
101    %bit:gpr(s64) = G_CONSTANT i64 8
102    %zero:gpr(s64) = G_CONSTANT i64 0
103
104    ; 7 does not have the third bit set.
105    %fold_cst:gpr(s64) = G_CONSTANT i64 7
106
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
110
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
115    G_BR %bb.0
116  bb.1:
117    RET_ReallyLR
118...
119---
120name:            dont_flip_ne
121alignment:       4
122legalized:       true
123regBankSelected: true
124body:             |
125  ; CHECK-LABEL: name: dont_flip_ne
126  ; CHECK: bb.0:
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
132  ; CHECK:   B %bb.0
133  ; CHECK: bb.1:
134  ; CHECK:   RET_ReallyLR
135  bb.0:
136    successors: %bb.0, %bb.1
137    liveins: $x0
138
139    ; Same as eq case, but we should get a TBNZW instead.
140
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
150    G_BR %bb.0
151  bb.1:
152    RET_ReallyLR
153...
154---
155name:            xor_chain
156alignment:       4
157legalized:       true
158regBankSelected: true
159body:             |
160  ; CHECK-LABEL: name: xor_chain
161  ; CHECK: bb.0:
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
167  ; CHECK:   B %bb.0
168  ; CHECK: bb.1:
169  ; CHECK:   RET_ReallyLR
170  bb.0:
171    successors: %bb.0, %bb.1
172    liveins: $x0
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
177
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
181
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
186    G_BR %bb.0
187  bb.1:
188    RET_ReallyLR
189