• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2
3# RUN: llc -mtriple aarch64 -debugify-and-strip-all-safe -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
4
5...
6---
7name:            fold_scalar
8tracksRegLiveness: true
9body:             |
10  bb.0:
11    liveins: $w0, $w1
12    ; (xor (and x, y), y) -> (and (not x), y)
13    ; CHECK-LABEL: name: fold_scalar
14    ; CHECK: liveins: $w0, $w1
15    ; CHECK: %x:_(s32) = COPY $w0
16    ; CHECK: %y:_(s32) = COPY $w1
17    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
18    ; CHECK: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]
19    ; CHECK: %xor:_(s32) = G_AND [[XOR]], %y
20    ; CHECK: $w0 = COPY %xor(s32)
21    ; CHECK: RET_ReallyLR implicit $w0
22    %x:_(s32) = COPY $w0
23    %y:_(s32) = COPY $w1
24    %and:_(s32) = G_AND %x, %y
25    %xor:_(s32) = G_XOR %and, %y
26    $w0 = COPY %xor(s32)
27    RET_ReallyLR implicit $w0
28
29...
30---
31name:            fold_vector
32tracksRegLiveness: true
33body:             |
34  bb.0:
35    liveins: $x0, $x1
36    ; Vector edition
37    ; CHECK-LABEL: name: fold_vector
38    ; CHECK: liveins: $x0, $x1
39    ; CHECK: %x:_(<2 x s32>) = COPY $x0
40    ; CHECK: %y:_(<2 x s32>) = COPY $x1
41    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
42    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32)
43    ; CHECK: [[XOR:%[0-9]+]]:_(<2 x s32>) = G_XOR %x, [[BUILD_VECTOR]]
44    ; CHECK: %xor:_(<2 x s32>) = G_AND [[XOR]], %y
45    ; CHECK: $x0 = COPY %xor(<2 x s32>)
46    ; CHECK: RET_ReallyLR implicit $x0
47    %x:_(<2 x s32>) = COPY $x0
48    %y:_(<2 x s32>) = COPY $x1
49    %and:_(<2 x s32>) = G_AND %x, %y
50    %xor:_(<2 x s32>) = G_XOR %and, %y
51    $x0 = COPY %xor(<2 x s32>)
52    RET_ReallyLR implicit $x0
53
54...
55---
56name:            fold_commuted_and
57tracksRegLiveness: true
58body:             |
59  bb.0:
60    liveins: $w0, $w1
61    ; (xor (and y, x), y) -> (and (not x), y)
62    ; CHECK-LABEL: name: fold_commuted_and
63    ; CHECK: liveins: $w0, $w1
64    ; CHECK: %x:_(s32) = COPY $w0
65    ; CHECK: %y:_(s32) = COPY $w1
66    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
67    ; CHECK: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]
68    ; CHECK: %xor:_(s32) = G_AND [[XOR]], %y
69    ; CHECK: $w0 = COPY %xor(s32)
70    ; CHECK: RET_ReallyLR implicit $w0
71    %x:_(s32) = COPY $w0
72    %y:_(s32) = COPY $w1
73    %and:_(s32) = G_AND %y, %x
74    %xor:_(s32) = G_XOR %and, %y
75    $w0 = COPY %xor(s32)
76    RET_ReallyLR implicit $w0
77
78...
79---
80name:            fold_commuted_xor
81tracksRegLiveness: true
82body:             |
83  bb.0:
84    liveins: $w0, $w1
85    ; (xor y, (and x, y)) -> (and (not x), y)
86    ; CHECK-LABEL: name: fold_commuted_xor
87    ; CHECK: liveins: $w0, $w1
88    ; CHECK: %x:_(s32) = COPY $w0
89    ; CHECK: %y:_(s32) = COPY $w1
90    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
91    ; CHECK: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]
92    ; CHECK: %xor:_(s32) = G_AND [[XOR]], %y
93    ; CHECK: $w0 = COPY %xor(s32)
94    ; CHECK: RET_ReallyLR implicit $w0
95    %x:_(s32) = COPY $w0
96    %y:_(s32) = COPY $w1
97    %and:_(s32) = G_AND %x, %y
98    %xor:_(s32) = G_XOR %y, %and
99    $w0 = COPY %xor(s32)
100    RET_ReallyLR implicit $w0
101
102...
103---
104name:            fold_commuted_xor_and
105tracksRegLiveness: true
106body:             |
107  bb.0:
108    liveins: $w0, $w1
109    ; (xor y, (and x, y)) -> (and (not x), y)
110    ; CHECK-LABEL: name: fold_commuted_xor_and
111    ; CHECK: liveins: $w0, $w1
112    ; CHECK: %x:_(s32) = COPY $w0
113    ; CHECK: %y:_(s32) = COPY $w1
114    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
115    ; CHECK: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]
116    ; CHECK: %xor:_(s32) = G_AND [[XOR]], %y
117    ; CHECK: $w0 = COPY %xor(s32)
118    ; CHECK: RET_ReallyLR implicit $w0
119    %x:_(s32) = COPY $w0
120    %y:_(s32) = COPY $w1
121    %and:_(s32) = G_AND %y, %x
122    %xor:_(s32) = G_XOR %y, %and
123    $w0 = COPY %xor(s32)
124    RET_ReallyLR implicit $w0
125
126...
127---
128name:            dont_fold_different_regs
129tracksRegLiveness: true
130body:             |
131  bb.0:
132    liveins: $w0, $w1, $w2
133    ; The G_AND does not share any registers with the G_XOR
134    ; CHECK-LABEL: name: dont_fold_different_regs
135    ; CHECK: liveins: $w0, $w1, $w2
136    ; CHECK: %x:_(s32) = COPY $w0
137    ; CHECK: %y:_(s32) = COPY $w1
138    ; CHECK: %z:_(s32) = COPY $w2
139    ; CHECK: %and:_(s32) = G_AND %x, %z
140    ; CHECK: %xor:_(s32) = G_XOR %and, %y
141    ; CHECK: $w0 = COPY %xor(s32)
142    ; CHECK: RET_ReallyLR implicit $w0
143    %x:_(s32) = COPY $w0
144    %y:_(s32) = COPY $w1
145    %z:_(s32) = COPY $w2
146    %and:_(s32) = G_AND %x, %z
147    %xor:_(s32) = G_XOR %and, %y
148    $w0 = COPY %xor(s32)
149    RET_ReallyLR implicit $w0
150
151...
152---
153name:            dont_fold_more_than_one_use
154tracksRegLiveness: true
155body:             |
156  bb.0:
157    liveins: $w0, $w1, $w2
158    ; Don't fold when the G_AND is used outside the G_XOR.
159    ;
160    ; CHECK-LABEL: name: dont_fold_more_than_one_use
161    ; CHECK: liveins: $w0, $w1, $w2
162    ; CHECK: %x:_(s32) = COPY $w0
163    ; CHECK: %y:_(s32) = COPY $w1
164    ; CHECK: %z:_(s32) = COPY $w2
165    ; CHECK: %and:_(s32) = G_AND %x, %z
166    ; CHECK: %xor:_(s32) = G_XOR %and, %y
167    ; CHECK: %add:_(s32) = G_ADD %and, %xor
168    ; CHECK: $w0 = COPY %add(s32)
169    ; CHECK: RET_ReallyLR implicit $w0
170    %x:_(s32) = COPY $w0
171    %y:_(s32) = COPY $w1
172    %z:_(s32) = COPY $w2
173    %and:_(s32) = G_AND %x, %z
174    %xor:_(s32) = G_XOR %and, %y
175    %add:_(s32) = G_ADD %and, %xor
176    $w0 = COPY %add(s32)
177    RET_ReallyLR implicit $w0
178