Commit 23595d1
authored
[AArch64] Lower __builtin_bswap16 to rev16 if bswap followed by any_extend (#105375)
GCC compiles the built-in function `__builtin_bswap16`, to the ARM
instruction rev16, which reverses the byte order of 16-bit data. On the
other Clang compiles the same built-in function to e.g.
```
rev w8, w0
lsr w0, w8, #16
```
i.e. it performs a byte reversal of a 32-bit register, (which moves the
lower half, which contains the 16-bit data, to the upper half) and then
right shifts the reversed 16-bit data back to the lower half of the
register.
We can improve Clang codegen by generating `rev16` instead of `rev` and
`lsr`, like GCC.1 parent 69f8923 commit 23595d1
File tree
3 files changed
+97
-5
lines changed- llvm
- lib/Target/AArch64
- test/CodeGen/AArch64
3 files changed
+97
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22379 | 22379 | | |
22380 | 22380 | | |
22381 | 22381 | | |
| 22382 | + | |
| 22383 | + | |
| 22384 | + | |
| 22385 | + | |
| 22386 | + | |
| 22387 | + | |
| 22388 | + | |
| 22389 | + | |
| 22390 | + | |
| 22391 | + | |
| 22392 | + | |
| 22393 | + | |
| 22394 | + | |
| 22395 | + | |
| 22396 | + | |
| 22397 | + | |
| 22398 | + | |
| 22399 | + | |
| 22400 | + | |
22382 | 22401 | | |
22383 | 22402 | | |
22384 | 22403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| 761 | + | |
| 762 | + | |
761 | 763 | | |
762 | 764 | | |
763 | 765 | | |
| |||
2840 | 2842 | | |
2841 | 2843 | | |
2842 | 2844 | | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
2843 | 2848 | | |
2844 | 2849 | | |
2845 | 2850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
8 | 75 | | |
9 | 76 | | |
10 | 77 | | |
11 | 78 | | |
12 | | - | |
13 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
14 | 82 | | |
15 | | - | |
16 | 83 | | |
| 84 | + | |
17 | 85 | | |
18 | 86 | | |
19 | 87 | | |
| |||
0 commit comments