-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8336245: AArch64: remove extra register copy when converting from long to pointer #20157
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -395,7 +395,14 @@ const class TypePtr *MachNode::adr_type() const { | |||||||||||
| // 32-bit unscaled narrow oop can be the base of any address expression | ||||||||||||
| t = t->make_ptr(); | ||||||||||||
| } | ||||||||||||
| if (t->isa_intptr_t() && offset != 0 && offset != Type::OffsetBot) { | ||||||||||||
|
|
||||||||||||
| if (t->isa_intptr_t() && | ||||||||||||
| #if !defined(AARCH64) | ||||||||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After applying the operand "IndirectX2P", we may have some patterns like: The code path here will resolve the I guess the code here was intended to support I don't think the limitation is applied to aarch64 machines now. So I unblock it for aarch64.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's the other way around. Isn't this code saying that if the address is an intptr + a nonzero offset, then the returned type is bottom, ie nothing? What effect does this change have?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for review! Yeah, this code says if the address is an Without the change here, an jdk/src/hotspot/share/opto/machnode.cpp Lines 409 to 413 in a96de6d
AFAIK, the return value
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I learn something every day, I guess. It's been a long while since I looked, but I expected "pointer to anything" to be TOP, not BOTTOM. Thinking some more, a |
||||||||||||
| // AArch64 supports the addressing mode: | ||||||||||||
| // [base, 0], in which [base] is converted from a long value | ||||||||||||
| offset != 0 && | ||||||||||||
| #endif | ||||||||||||
| offset != Type::OffsetBot) { | ||||||||||||
| // We cannot assert that the offset does not look oop-ish here. | ||||||||||||
| // Depending on the heap layout the cardmark base could land | ||||||||||||
| // inside some oopish region. It definitely does for Win2K. | ||||||||||||
|
|
||||||||||||
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.
Why is this using hard wired constants rather than using Address::offset_ok_for_immed?
Also, why is the constant value 65520?
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.
I think
Address::offset_ok_for_immedis too restrictive: we want a predicate that is the superset of all possible address offsets.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.
Yes, I realise that this is 16 less than 65536. However, there are two things I don't follow.
In the original code immLoffset was only used to define indOffLN i.e. a long offset used with a narrow pointer. The use of Address::offset_ok_for_immed(n->get_long(), 0) in the predicate limited narrow pointer offsets to -256 <= offset <= (2^12 - 1). With this change the top end of the range is now (2^12 - 1) << 4. I am wondering why that is appropriate?
The change allows immLOffset to be used in the definition of indOffX2P. I am not clear why indOffX2P is not just defined using the existing operand immLoffset16 which has as its predicate Address::offset_ok_for_immed(n->get_long(), 4). The only difference I can see is that the alternative predicate used here will accept a positive offset that is not 16 byte aligned. Is that the intention of the redefinition? Again, why is that appropriate?
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.
After this change,
immLOffsetis a more general-purpose type thanimmLoffset16.immLOffsetmatches all possible address offsets, along with some impossible ones. For example, it matches all of the misalignedUnsafeaccesses at any offset, regardless of operand size. In the (rare) event that an operand size and offset don't fit a single instruction, we'll split the instruction when we emit it.After this patch there will be a few rare cases where we have a regression in code size, but it's worth it for the simplicity and the size of the matcher logic, which would otherwise explode. I don't expect any significant regression in execution time.
This patch is not the last word on the matter; later patches may well further reduce the number of integer offset types in a similar way. I don't think that many of the offsetL/I/X/P types do anything useful, and we'd probably profit from removing them, but that's another patch for anther day.
Uh oh!
There was an error while loading. Please reload this page.
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.
Ok, I see. The use of immLoffset as defined in this patch is actually correct for narrow oops and, indeed, for all other address base types. It allows for all possible offsets that might fit into a load an immediate slot. Whether we can legitimately encode the operand offset as an immediate or need instead to use an auxiliary add does not actually depend on the type of the address base but on the size of the datum fetched by the indirect load that consumes the operand. So, an indirect operand with offset 4098 would be too big to encode in an ldrb, fine to encode in an ldrh and invalid for encoding in an ldrw or ldrx because it is not suitably aligned.
That does imply we should get rid of the other (now redundant) immLoffset operands. However, we can do that in a follow-up patch because it is not what this fix is addressing