Changes ordering of CSEL and CMP to match ternary operator #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the ARM documentation it says that given
CSEL Rd, Rn, Rm, cond
,Rd = if cond then Rn else Rm, where R is either W or X
.The comparison in
FindOldestPerson
iscmp w2, w5
which means that it seems to be comparing ifw2 > w5
instead of ifw5 > w2
, and the operands to CSEL are flipped. That means that it sets the oldest person to the current person if the oldest person's age is less than or equal to the current person's age. This looks different from the C ternary operator version below that explains how the instruction works.This PR modifies the order of the
cmp
and the operands incsel
to more closely match the logic in the equivalent C code.Here is a sample run of the current
FindOldestPerson
function. Notice that there are two people with age4992
, but the last one is returned as the oldest person.Here is a sample run of the program after the changes in the PR. Now the first person with the oldest age will be returned as the oldest person.