-
Notifications
You must be signed in to change notification settings - Fork 152
[CIR] Use ComplexRealOp for RValue __real__
operator
#1689
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
base: main
Are you sure you want to change the base?
Conversation
CC. @andykaylor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
// CHECK-AFTER: } | ||
|
||
// LLVM: define dso_local void @extract_real() | ||
// LLVM: %{{.+}} = load double, ptr @c, align 8 | ||
// LLVM: %{{.+}} = load i32, ptr @ci, align 4 | ||
// LLVM: %[[COMPLEX_D:.*]] = load { double, double }, ptr @c, align 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not great that we're loading the whole complex value when we only need one component, but hopefully the optimizer will do something about that. If necessary, we can create a CIR-specific transform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, we can check if it is handled by the optimiser, or we can create our own transform. I will create a PR for __imag__
:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is cir.complex.real_ptr
used at all after this PR? If so the operation should also be removed
Yes __real__ c = 10; |
Update
__real__
operation to use ComplexRealOp and act directly on the complex value.Ref: llvm/llvm-project#144235 (review)