Commit 4fdf07f
authored
[AArch64] Use CNEG for absolute difference patterns. (#151177)
The current code generated for absolute difference patterns
(a > b ? a - b : b - a) typically consists of sequences of:
```
sub w8, w1, w0
subs w9, w0, w1
csel w0, w9, w8, hi
```
The first sub is redundant if the csel is replaced by a cneg:
```
subs w8, w0, w1
cneg w0, w8, ls
```
This is achieved by canonicalising
```
select_cc lhs, rhs, sub(lhs, rhs), sub(rhs, lhs), cc ->
select_cc lhs, rhs, sub(lhs, rhs), neg(sub(lhs, rhs)), cc
select_cc lhs, rhs, sub(rhs, lhs), sub(lhs, rhs), cc ->
select_cc lhs, rhs, neg(sub(lhs, rhs)), sub(lhs, rhs), cc
```
as the second forms can already be matched.
This helps with some of the patterns in #118413.1 parent 0d8abc2 commit 4fdf07f
File tree
6 files changed
+112
-164
lines changed- llvm
- lib/Target/AArch64
- test/CodeGen/AArch64
6 files changed
+112
-164
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11386 | 11386 | | |
11387 | 11387 | | |
11388 | 11388 | | |
| 11389 | + | |
| 11390 | + | |
| 11391 | + | |
| 11392 | + | |
| 11393 | + | |
| 11394 | + | |
| 11395 | + | |
| 11396 | + | |
| 11397 | + | |
| 11398 | + | |
| 11399 | + | |
| 11400 | + | |
| 11401 | + | |
| 11402 | + | |
| 11403 | + | |
| 11404 | + | |
11389 | 11405 | | |
11390 | 11406 | | |
11391 | 11407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 80 | + | |
| 81 | + | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
| |||
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 112 | + | |
| 113 | + | |
118 | 114 | | |
119 | 115 | | |
120 | 116 | | |
| |||
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 128 | + | |
| 129 | + | |
136 | 130 | | |
137 | 131 | | |
138 | 132 | | |
| |||
146 | 140 | | |
147 | 141 | | |
148 | 142 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 143 | + | |
| 144 | + | |
153 | 145 | | |
154 | 146 | | |
155 | 147 | | |
| |||
163 | 155 | | |
164 | 156 | | |
165 | 157 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 158 | + | |
| 159 | + | |
170 | 160 | | |
171 | 161 | | |
172 | 162 | | |
| |||
180 | 170 | | |
181 | 171 | | |
182 | 172 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 173 | + | |
| 174 | + | |
187 | 175 | | |
188 | 176 | | |
189 | 177 | | |
| |||
359 | 347 | | |
360 | 348 | | |
361 | 349 | | |
362 | | - | |
363 | | - | |
364 | | - | |
| 350 | + | |
| 351 | + | |
365 | 352 | | |
366 | 353 | | |
367 | 354 | | |
| |||
373 | 360 | | |
374 | 361 | | |
375 | 362 | | |
376 | | - | |
377 | | - | |
378 | | - | |
| 363 | + | |
| 364 | + | |
379 | 365 | | |
380 | 366 | | |
381 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | 76 | | |
78 | | - | |
| 77 | + | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 106 | + | |
| 107 | + | |
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
| |||
120 | 118 | | |
121 | 119 | | |
122 | 120 | | |
123 | | - | |
124 | 121 | | |
125 | | - | |
| 122 | + | |
126 | 123 | | |
127 | 124 | | |
128 | 125 | | |
| |||
135 | 132 | | |
136 | 133 | | |
137 | 134 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 135 | + | |
| 136 | + | |
141 | 137 | | |
142 | 138 | | |
143 | 139 | | |
| |||
150 | 146 | | |
151 | 147 | | |
152 | 148 | | |
153 | | - | |
154 | | - | |
155 | | - | |
| 149 | + | |
| 150 | + | |
156 | 151 | | |
157 | 152 | | |
158 | 153 | | |
| |||
165 | 160 | | |
166 | 161 | | |
167 | 162 | | |
168 | | - | |
169 | | - | |
170 | | - | |
| 163 | + | |
| 164 | + | |
171 | 165 | | |
172 | 166 | | |
173 | 167 | | |
| |||
248 | 242 | | |
249 | 243 | | |
250 | 244 | | |
251 | | - | |
252 | | - | |
253 | | - | |
| 245 | + | |
| 246 | + | |
254 | 247 | | |
255 | 248 | | |
256 | 249 | | |
| |||
261 | 254 | | |
262 | 255 | | |
263 | 256 | | |
264 | | - | |
265 | | - | |
266 | | - | |
| 257 | + | |
| 258 | + | |
267 | 259 | | |
268 | 260 | | |
269 | 261 | | |
| |||
324 | 316 | | |
325 | 317 | | |
326 | 318 | | |
327 | | - | |
328 | | - | |
329 | | - | |
| 319 | + | |
| 320 | + | |
330 | 321 | | |
331 | 322 | | |
332 | 323 | | |
| |||
338 | 329 | | |
339 | 330 | | |
340 | 331 | | |
341 | | - | |
342 | | - | |
343 | | - | |
| 332 | + | |
| 333 | + | |
344 | 334 | | |
345 | 335 | | |
346 | 336 | | |
| |||
572 | 562 | | |
573 | 563 | | |
574 | 564 | | |
575 | | - | |
576 | | - | |
577 | | - | |
| 565 | + | |
| 566 | + | |
578 | 567 | | |
579 | 568 | | |
580 | 569 | | |
| |||
586 | 575 | | |
587 | 576 | | |
588 | 577 | | |
589 | | - | |
590 | | - | |
591 | | - | |
| 578 | + | |
| 579 | + | |
592 | 580 | | |
593 | 581 | | |
594 | 582 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 80 | + | |
| 81 | + | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
| |||
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 112 | + | |
| 113 | + | |
118 | 114 | | |
119 | 115 | | |
120 | 116 | | |
| |||
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 128 | + | |
| 129 | + | |
136 | 130 | | |
137 | 131 | | |
138 | 132 | | |
| |||
146 | 140 | | |
147 | 141 | | |
148 | 142 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 143 | + | |
| 144 | + | |
153 | 145 | | |
154 | 146 | | |
155 | 147 | | |
| |||
163 | 155 | | |
164 | 156 | | |
165 | 157 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 158 | + | |
| 159 | + | |
170 | 160 | | |
171 | 161 | | |
172 | 162 | | |
| |||
180 | 170 | | |
181 | 171 | | |
182 | 172 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 173 | + | |
| 174 | + | |
187 | 175 | | |
188 | 176 | | |
189 | 177 | | |
| |||
363 | 351 | | |
364 | 352 | | |
365 | 353 | | |
366 | | - | |
367 | | - | |
368 | | - | |
| 354 | + | |
| 355 | + | |
369 | 356 | | |
370 | 357 | | |
371 | 358 | | |
| |||
377 | 364 | | |
378 | 365 | | |
379 | 366 | | |
380 | | - | |
381 | | - | |
382 | | - | |
| 367 | + | |
| 368 | + | |
383 | 369 | | |
384 | 370 | | |
385 | 371 | | |
| |||
0 commit comments