RFR: 8343685: C2 SuperWord: refactor VPointer with MemPointer [v6]
Emanuel Peter
epeter at openjdk.org
Wed Jan 15 15:00:11 UTC 2025
On Wed, 15 Jan 2025 11:58:49 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> More fixes for vnkozlov
>
> src/hotspot/share/opto/vectorization.hpp line 732:
>
>> 730: const jint _iv_scale;
>> 731:
>> 732: const bool _is_valid;
>
> Can you add a comment here what it means when a `VPointer` is invalid and how this is possible to end up with an invalid `VPointer`?
I simply rewrote the whole comment above `VPointer`, to be hopefully more helpful:
// Reminder: MemPointer have the form:
//
// pointer = SUM(summands) + con
//
// Where every summand in summands has the form:
//
// summand = scale * variable
//
// The VPointer wraps a MemPointer for the use in loops. A "valid" VPointer has
// the form:
//
// pointer = base + invar + iv_scale * iv + con
//
// invar = SUM(invar_summands)
//
// Where:
// - base: is the known base of the MemPointer.
// on-heap (object base) or off-heap (native base address)
// - iv and iv_scale: i.e. the iv_summand = iv * iv_scale.
// If we find a summand where the variable is the iv, we set iv_scale to the
// corresponding scale. If there is no such summand, then we know that the
// pointer does not depend on the iv, since otherwise there would have to be
// a summand where its variable is main-loop variant.
// - invar_summands: all other summands except base and iv_summand.
// All variables must be pre-loop invariant. This is important when we need
// to memory align a pointer using the pre-loop limit.
//
// A VPointer can be marked "invalid", if some of these conditions are not met, or
// it is unknown if they are met. If a VPointer is marked "invalid", it always
// returns conservative answers to aliasing queries, which means that we do not
// optimize in these cases. For example:
// - is_adjacent_to_and_before: returning true would allow optimizations such as
// packing into vectors. So for "invalid" VPointers
// we always return false (i.e. unknown).
// - never_overlaps_with: returning true would allow optimizations such as
// swapping the order of memops. So for "invalid" VPointers
// we always return false (i.e. unknown).
//
// These are examples where a VPointer becomes "invalid":
// - If the MemPointer does not have the required form for VPointer,
// i.e. if one of these conditions is not met (see init_is_valid):
// - Base must be known.
// - All summands except the iv-summand must be pre-loop invariant.
// - Some restrictions on iv_scale and iv_stride, to avoid overflow in
// alignment computations.
// - If the new con computed in make_with_iv_offset overflows.
//
class VPointer : public ArenaObj {
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21926#discussion_r1916800978
More information about the hotspot-compiler-dev
mailing list