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

Future improvements: 3 way comparison use upcoming LLVM intrinsics #514

Closed
bcardosolopes opened this issue Mar 19, 2024 · 4 comments
Closed

Comments

@bcardosolopes
Copy link
Member

          As a side note for potential future improvements: LLVM now has an [RFC](https://discourse.llvm.org/t/rfc-add-3-way-comparison-intrinsics/76685) that adds 3-way comparison intrinsic. LLVM folks believe this new intrinsic can generate better code for various targets. This project will be done in GSoC2024 and when it's done we can consider lowering `cir.cmp3way` to it directly.

Originally posted by @Lancern in #485 (comment)

@bcardosolopes
Copy link
Member Author

It's already in tree: llvm/llvm-project@276847a65af6
Even though we synced with upstream couple weeks ago, we missed this one, but should be available after next round of updates.

@Lancern
Copy link
Member

Lancern commented Apr 4, 2024

@bcardosolopes This is awesome! I'll make a PR once this commit gets merged into our repo.

@Lancern
Copy link
Member

Lancern commented Apr 18, 2024

It's already in tree: llvm/llvm-project@276847a65af6

Looks like the commit has been merged into this repo. I'll start working on this.

bcardosolopes pushed a commit that referenced this issue Apr 23, 2024
LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses #514 .
lanza pushed a commit that referenced this issue Apr 29, 2024
LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses #514 .
lanza pushed a commit that referenced this issue Apr 29, 2024
LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses #514 .
lanza pushed a commit that referenced this issue Apr 29, 2024
LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses #514 .
@Lancern
Copy link
Member

Lancern commented May 7, 2024

This issue is finished and can be closed.

bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this issue Oct 2, 2024
…#556)

LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses llvm#514 .
Hugobros3 pushed a commit to shady-gang/clangir that referenced this issue Oct 2, 2024
…#556)

LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses llvm#514 .
keryell pushed a commit to keryell/clangir that referenced this issue Oct 19, 2024
…#556)

LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses llvm#514 .
lanza pushed a commit that referenced this issue Nov 5, 2024
LLVM recently added two families of intrinsics named `llvm.scmp.*` and
`llvm.ucmp.*` that generate potentially better code for three-way
comparison operations. This PR lowers certain `cir.cmp3way` operations
to these intrinsics.

Not all `cir.cmp3way` operations can be lowered to these intrinsics. The
qualifying conditions are: 1) the comparison is between two integers,
and 2) the comparison produces a strong ordering. `cir.cmp3way`
operations that are not qualified are not affected by this PR.

Qualifying `cir.cmp3way` operations may still need some canonicalization
work before lowering. The "canonicalized" form of a qualifying three-way
comparison operation yields -1 for lt, 0 for eq, and 1 for gt. This PR
converts those non-canonicalized but qualifying `cir.cmp3way` operations
to their canonical forms in the LLVM lowering prepare pass.

This PR addresses #514 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants