Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Aug 2, 2024

Addresses @AndyAyersMS's concerns in #105441 (comment)

TL;DR - some instructions relax their semantics when ZR register is used as target. LLVM avoids that via atomicBarrierDroppedOnZero and atomicBarrierDroppedOnZero

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 2, 2024
@EgorBo EgorBo marked this pull request as ready for review August 2, 2024 06:30
@EgorBo
Copy link
Member Author

EgorBo commented Aug 2, 2024

@AndyAyersMS @dotnet/jit-contrib cc @VSadov PTAL, no diffs. I am not sure LSRA can ever decide to assign a zero reg as target reg so my availableIntRegs & ~(SRBM_ZR) is likely unnecessary (UPD: removed). But what used to be possible is that LSRA could assign REG_NA for target (when it's unused) and the codegen used ZR reg to discard the result.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we might need more of this elsewhere?

@EgorBo
Copy link
Member Author

EgorBo commented Aug 2, 2024

Seems like we might need more of this elsewhere?

Can you please point me to any? There is one more place with INS_casal* but it's not affected by ZR.

@AndyAyersMS
Copy link
Member

Seems like we might need more of this elsewhere?

Can you please point me to any? There is one more place with INS_casal* but it's not affected by ZR.

I don't know of any -- just that LLVM has relatively large lists for both cases.

@AndyAyersMS AndyAyersMS merged commit 53a500e into dotnet:main Aug 5, 2024
@EgorBo
Copy link
Member Author

EgorBo commented Aug 10, 2024

just that LLVM has relatively large lists for both cases.

Yeah the list of instructions is big, but we don't use any besides these in my PR. Arm64 has many interesting atomic instructions like "atomic min/max, atomic bit-clear/bit-set" but .NET doesn't have APIs for them/doesn't try to recognize idioms

@EgorBo EgorBo deleted the improve-ordering-lse branch August 10, 2024 21:49
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2024
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants