dotnet / dotnet/runtime

arm64: Investigate using adds and changing the subsequent compare suffix to match expected dotnet behaviour

Open
#121,445 3 comments 0 reactions 1 assignee Claimed by @jonathandavies-arm View on GitHub
area-CodeGen-coreclr
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

If we have the following instructions
```
add w0, w0, w1
cmp w0, #0
cset w0, gt
```

we would like to use the `adds` instruction so that the flags are set during the adds and we don't need a separate `cmp` instruction.

The issue is that without changing the cset suffix we will get an incorrect results if the add results in an overflow. We would need to check that the result is positive and not zero.

See these 2 comments:
https://github.com/dotnet/runtime/pull/121380#discussion_r2499819365
https://github.com/dotnet/runtime/pull/121380#discussion_r2499846412

This should also be done for subs and negs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.