Commit cba8fe8
committed
cmd/compile: fold single-bit TST; CSET NE into UBFX on arm64
A boolean materialized from a single-bit test compiles to
TST $(1<<k); CSET NE. The bit is a bitfield extract: rewrite the
NotEqual of a one-bit TSTconst/TSTWconst to UBFX #k, #1, the value
form of the existing single-bit TBZ/TBNZ branch rules. The flags
producer remains for any other reader, and a shared bool's branch
then tests the extracted bit directly, so the TST disappears there
too.
Measured with armlint on darwin/arm64:
cmd/go: 166 TST; CSET pairs eliminated, __text -672 bytes.
gofmt: 35 pairs eliminated, __text -192 bytes.1 parent 31525e9 commit cba8fe8
3 files changed
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
573 | 579 | | |
574 | 580 | | |
575 | 581 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
330 | 346 | | |
331 | 347 | | |
332 | 348 | | |
| |||
0 commit comments