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

[CIR][LLVMLowering] Add LLVM lowering for complex operations #723

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

Lancern
Copy link
Collaborator

@Lancern Lancern commented Jul 7, 2024

This PR adds LLVM lowering for the following operations related to complex numbers:

  • cir.complex.create,
  • cir.complex.real_ptr, and
  • cir.complex.imag_ptr.

The LLVM IR generated for cir.complex.create is a bit ugly since it includes the insertvalue instruction, which typically is not generated in upstream CodeGen. Later we may need further CIR canonicalization passes to try folding cir.complex.create.

This patch adds LLVM lowering for the following operations related to complex
numbers: 1) `cir.complex.create`, 2) `cir.complex.real_ptr`, and
3)`cir.complex.imag_ptr`.
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, will merge after the question below

The LLVM IR generated for cir.complex.create is a bit ugly since it includes the insertvalue instruction, which typically is not generated in upstream CodeGen. Later we may need further CIR canonicalization passes to try folding cir.complex.create.

Awesome! Is the insertvalue solely because we need better canonicalization at the CIR level? Can you please create an issue with the examples that need to be improved? Perhaps such canonicalization can be done in ComplexCreateOp::fold.

@Lancern
Copy link
Collaborator Author

Lancern commented Jul 9, 2024

Is the insertvalue solely because we need better canonicalization at the CIR level?

Yes, we currently cannot avoid this unless we could eliminate cir.complex.create entirely during canonicalization.

Can you please create an issue with the examples that need to be improved? Perhaps such canonicalization can be done in ComplexCreateOp::fold.

Created #726 to track this.

@bcardosolopes bcardosolopes merged commit 80e1a10 into llvm:main Jul 9, 2024
7 checks passed
@Lancern Lancern deleted the basic-complex-lowering branch July 9, 2024 02:39
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.

None yet

2 participants