arm64: Add support for BFI and BFX instruction#123138
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
ce512bf to
1a8d58f
Compare
1a8d58f to
83a6004
Compare
|
Spmidiff errors |
- Remove Expect.cs
Fixed |
|
/azp run runtime-coreclr superpmi-replay |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Looks like there are replay failures.
|
|
The throughput regressions in the diffs seem large given the quite small number of diffs and the complexity of the transformation. All the diffs I looked at looked like: - lsr w2, w0, #6
- and w2, w2, #63
+ ubfx w2, w0, #6, #6and - lsr w2, w0, #6
- and w2, w2, #63
+ ubfx w2, w0, #6, #6Could we simplify things by only focusing on these cases? |
I'll have a look at reducing what the PR does to concentrate on this pattern. |
I've pushed a commit that only focuses on the small case you suggested. From my local testing the throughput regressions should be no more, I would check the build but I can't find the page with the results. |
- Remove BFX case from compiler.hpp and gentree.cpp
|
/azp run runtime-coreclr superpmi-replay |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This patch adds support for the Arm BFX instruction.
When you extract a continuous range of bits from an integer e.g.
`return (x >> 5) & 0x1F;`
This is the node pattern it's looking for
```
N005 ( 5, 7) [000004] -----+----- \--* AND int $101
N003 ( 3, 4) [000002] -----+----- +--* RSH int $100
N001 ( 1, 1) [000000] -----+----- | +--* LCL_VAR int V00 arg0 u:1 (last use) $80
N002 ( 1, 2) [000001] -----+----- | \--* CNS_INT int 6 $42
N004 ( 1, 2) [000003] -----+----- \--* CNS_INT int 63 $43
```
and changes to
```
( 5, 7) [000007] ----------- \--* BFX int
N001 ( 1, 1) [000000] -----+----- \--* LCL_VAR int V00 arg0 u:1 (last use) $80
```
This patch adds support for the Arm BFI and BFX instructions. I've added a optimisation in lowering for bit packing and unpacking using each instruction respectively.
BFI
This is used when you pack 2 or more values into an integer. e.g.
return (a & 0xf) | ((b & 0x3) << 4);This is the node pattern it is looking for
and changes to
BFX
When you extract a continuous range of bits from an integer. This is the inverse of above. e.g.
return (x >> 5) & 0x1F;This is the node pattern it's looking for
and changes to