Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm64: Support additional condition checks in select nodes #78223

Merged
merged 1 commit into from
Nov 14, 2022

Conversation

a74nh
Copy link
Contributor

@a74nh a74nh commented Nov 11, 2022

Generating a FEQ or FNEU can generate an incorrect compare.

Firstly, the optimizer needs changing to ensure the NAN flag is correct.

Once that is fixed, it's not possible to generate a test to trigger the code in codegen (as there are no CIL beq.un or bne instructions). However, the codegen code was wrong.

Alternatively, given it's untested, it might be better to replace the codegen changes with some asserts?

I've added some general compare consume tests to ensure everything is generated ok.

Generating a FEQ or FNEU will generate an incorrect compare.

With the optimizer code fixed, it's not possible to generate a
test to trigger the code in codegen. However, the code as it is was
wrong. Given it's untested, it might be better to replace it with
some asserts?

I've added some general compare consume tests to ensure everything
is generated ok.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 11, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 11, 2022
@ghost
Copy link

ghost commented Nov 11, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Generating a FEQ or FNEU can generate an incorrect compare.

Firstly, the optimizer needs changing to ensure the NAN flag is correct.

Once that is fixed, it's not possible to generate a test to trigger the code in codegen (as there are no CIL beq.un or bne instructions). However, the codegen code was wrong.

Alternatively, given it's untested, it might be better to replace the codegen changes with some asserts?

I've added some general compare consume tests to ensure everything is generated ok.

Author: a74nh
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@a74nh
Copy link
Contributor Author

a74nh commented Nov 14, 2022

Test failures look like failure to connect to services and missing spmi logs.

@jakobbotsch
Copy link
Member

Once that is fixed, it's not possible to generate a test to trigger the code in codegen (as there are no CIL beq.un or bne instructions). However, the codegen code was wrong.

I assume it can happen due to morph calling gtReverseCond itself in a bunch of places?

I think I've commented on this before, but I really would prefer if we just swapped the operands in the select node we create below (which seems more obviously correct to me, without having to rely on gtReverseCond not hitting the GT_NOT case).

@jakobbotsch jakobbotsch reopened this Nov 14, 2022
@a74nh
Copy link
Contributor Author

a74nh commented Nov 14, 2022

I assume it can happen due to morph calling gtReverseCond itself in a bunch of places?

It's not quite that simple - you can't reverse a "single op" compare reverse into a non single op compare.

Ordered Float NE -> Unordered Float EQ -> Ordered Float NE -> etc (always multi op)
Unordered Float NE -> Ordered Float EQ -> Unordered Float NE -> etc (always single op)

@jakobbotsch
Copy link
Member

It's not quite that simple - you can't reverse a "single op" compare reverse into a non single op compare.

Gotcha, makes sense. So essentially we never see these multi-ops on ARM64.

Alternatively, given it's untested, it might be better to replace the codegen changes with some asserts?

I will leave it up to you. The handling you added in this PR in the backend looks innocent/correct enough.

@a74nh
Copy link
Contributor Author

a74nh commented Nov 14, 2022

I will leave it up to you. The handling you added in this PR in the backend looks innocent/correct enough.

Ok, will leave as is then.

@jakobbotsch
Copy link
Member

Failures are #78290 (the CI run started right before the fix was merged)

@a74nh
Copy link
Contributor Author

a74nh commented Nov 14, 2022

Failures are #78290 (the CI run started right before the fix was merged)

Are you sure? This PR isn't merged yet.

@jakobbotsch
Copy link
Member

I mean the CI failures in this PR are #78290 (which is fixed, but the fix for that issue didn't make it to this PR's CI run).

@a74nh
Copy link
Contributor Author

a74nh commented Nov 14, 2022

I mean the CI failures in this PR are #78290 (which is fixed, but the fix for that issue didn't make it to this PR's CI run).

Ah, sorry, Understood.

@jakobbotsch jakobbotsch merged commit 4276f06 into dotnet:main Nov 14, 2022
@a74nh a74nh deleted the github_gencond branch November 16, 2022 10:29
@ghost ghost locked as resolved and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants