Repository navigation
Emit cmp (extended register) on ARM64 to simplify cast-then-compare expressions - #112411
Conversation
… expressions Working towards dotnet#68028
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
| { | ||
| return true; | ||
| } | ||
| castOp->ClearContained(); |
There was a problem hiding this comment.
Some assertions hit related to register allocation if we don't clear it here. The problem is with chains such as:
ADD(
op1,
CAST(
LCL_VAR
)
)
Usually the LCL_VAR node will be contained by the CAST node, this allows a later optimization using LDRB/H to perform the cast with load. The register will be allocated to the CAST node which is then used by the ADD. If we contain the CAST and the LCL_VAR spills, then both the CAST and LCL_VAR nodes won't have a register allocated when we try to generate the ADD. If I understand correctly, it's not possible to tell whether a LCL_VAR will be spilled until after register allocation, but you can force the casted node into a register and contain the CAST node instead.
In most cases the casted node is a register value and the containment from CAST -> LCL_VAR had no effect, so this will result in removing the cast instruction. However, if the casted node is spilled then you would see LDR used (no cast), and the ADD node will use the cast extension, which is the behavior I'm preserving here. I've moved these containment settings from ContainCheckBinary to here because they were causing side effects with the comparison nodes.
This problem also applies to the comparison nodes, which is why I clear the RegOptional flag on some nodes.
|
looks like there is a test failure . Can you please double check if it is caused with this PR? |
It looks like this failed on "Send to Helix", is this a network error? I can't see any failing build or test output. |
You can see the test output by going to Tests -> System.Runtime.Intrinsics.Tests Work item -> Artifacts -> Console Logs. That takes you to this link: https://helixr1107v0xdcypoyl9e7f.blob.core.windows.net/dotnet-runtime-refs-pull-112411-merge-30e75b278b4d4c6eae/System.Runtime.Intrinsics.Tests/1/console.cb1ccbdb.log?helixlogtype=result In this case the failure looks like known failure #111922. |
| if (parentNode->OperIs(GT_CMP)) | ||
| { | ||
| if (IsInvariantInRange(childNode, parentNode)) | ||
| castOp->ClearContained(); |
There was a problem hiding this comment.
It looks odd to me that a function called IsContainableUnaryOrBinaryOp mutates random trees. Can this be done by the caller instead?
There was a problem hiding this comment.
Thanks, fixed this
Working towards #68028
Matching on
GT_EQ/NE/...nodes containingGT_CAST.Example: