RFR: 8282722: Regard mapping array in enum switches as stable for constant folding
Jatin Bhateja
jbhateja at openjdk.java.net
Mon Mar 7 11:24:58 UTC 2022
On Mon, 7 Mar 2022 07:13:20 GMT, Joshua Zhu <jzhu at openjdk.org> wrote:
> I came across a performance issue when using scatter store VectorAPI for Integer and Long simultaneously in the same application. The poor performance was caused by vector intrinsic inlining failure because of non-determined IntSpecies for a constant VectorShape of IndexMap in this scenario.
>
> For ScatterStore operation of LongVector.SPECIES_512/IntVector.SPECIES_512, VectorShape.S_256_BIT/S_512_BIT is the actual length of indexMap vector respectively.
>
> IntSpecies species(VectorShape s)
>
> returns the corresponding IntSpecies by Switch on Enum type "VectorShape". [1]
>
> With this change introduced, elements in the SwitchMap array (initialized in clinit) can be constant-folded so that determined IntSpecies can be acquired for a constant VectorShape.
>
> jtreg test passed without new failure.
> Please help review this change and let me know if any comments.
>
> [1] https://github.com/openjdk/jdk/blob/894ffb098c80bfeb4209038c017d01dbf53fac0f/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java#L4043
Fix is checking an integer array field name starting with "$SwitchMap" to be marked as stable if it is decorated with ACC_STATIC | ACC_FINAL attributes. Wandering why is not being honored during constant folding currently.
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/ci/ciField.hpp#L129
// Is this field a constant?
//
// Clarification: A field is considered constant if:
// 1. The field is both static and final
// 2. The field is not one of the special static/final
// non-constant fields. These are java.lang.System.in
// and java.lang.System.out. Abomination.
//
// A field is also considered constant if
// - it is marked @Stable and is non-null (or non-zero, if a primitive) or
// - it is trusted or
// - it is the target field of a CallSite object.
//
// See ciField::initialize_from() for more details.
//
// A user should also check the field value (constant_value().is_valid()), since
// constant fields of non-initialized classes don't have values yet.
bool is_constant() const { return _is_constant; }
-------------
PR: https://git.openjdk.java.net/jdk/pull/7721
More information about the hotspot-dev
mailing list