Skip to content

Conversation

@badumbatish
Copy link
Contributor

@badumbatish badumbatish commented Sep 5, 2025

Fixes #1818

  • Implement createVecCompare, getCIRIntOrFloatBitWidth, getVectorFCmpIR helper for
    VecCmp op creation.
  • Add clang/test/CIR/CodeGen/builtin-fcmp-sse.c test.

in OG, there is a sext from bool to int before casting to float vector since fcmp's result in llvm ir is boolean-like, while VecCmpOp in CIR returns int in the form of 0 or -1.

There is also a boolean shouldInvert in CIR since CIR doesn't contain optimized unordered comparison, for example: OLE is the inverse predicate of UGT. So if we need UGT, we have to pass in OLE and shouldInvert = true

@badumbatish
Copy link
Contributor Author

badumbatish commented Sep 5, 2025

For clang/test/CIR/Lowering/vectype.cpp and clang/test/CIR/CodeGen/vectype-ext.cpp, i modified it to fit OG, I can add extra tests to those as well

Copy link
Collaborator

@tommymcm tommymcm left a comment

Choose a reason for hiding this comment

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

There are some soundness issues here. I don't think making VecCmpOp ordered or unordered is the solution, it goes agains the semantics of C/C++.

- Implement createVecCompare, getCIRIntOrFloatBitWidth, getVectorFCmpIR helper for
  VecCmp op creation.
- Add clang/test/CIR/CodeGen/builtin-fcmp-sse.c test.
Copy link
Collaborator

@tommymcm tommymcm left a comment

Choose a reason for hiding this comment

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

Here's some pointers for matching the skeleton.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

LGTM with one minot nit.

thanks for your patience!

@bcardosolopes bcardosolopes merged commit 9fc2a91 into llvm:main Sep 22, 2025
9 checks passed
@badumbatish badumbatish deleted the cmpnlepd branch September 23, 2025 00:15
bcardosolopes pushed a commit that referenced this pull request Sep 25, 2025
This PR adds supports for __builtin_ia32_cmpnltps/cmpnltpd.

Depends on #1893.
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

Successfully merging this pull request may close these issues.

[CIR][CodeGen][Builtin] __builtin_ia32_cmpnleps and __builtin_ia32_cmpnlepd

3 participants