[vector] binary operations with a scalar

Paul Sandoz paul.sandoz at oracle.com
Sat Feb 17 01:58:02 UTC 2018


I am hoping it's possible to push the intrinsic down into VectorIntrinsics, for example:

VectorIntrinsics:
—

    @HotSpotIntrinsicCandidate
    static <S extends Vector.Shape>
    IntVector<S> binaryOpInt(int oprId, Class<? extends IntVector<S>> vectorClass, Class<?> elementType, int vlen,
                             IntVector<S> v1, int s2, /*Vector.Mask<E,S> m,*/
                             BiFunction<IntVector<S>,IntVector<S>,IntVector<S>> defaultImpl) {
        return binaryOp(oprId, vectorClass, elementType, vlen,
                        v1, v1.species().broadcast(s2), defaultImpl);
    }


Int256Vector
—

@Override
@ForceInline
public Int256Vector add(int o) {
    return (Int256Vector) VectorIntrinsics.binaryOpInt(
        VECTOR_OP_ADD, Int256Vector.class, int.class, LENGTH,
        this, o,
        (v1, v2) -> ((Int256Vector)v1).bOp(v2, (i, a, b) -> (int)(a + b)));
}

that leaves the broadcast for the non-intrinsic case, and it’s possible to clean that up later on with a more specialized function.

Paul.


> On Feb 16, 2018, at 5:30 PM, Viswanathan, Sandhya <sandhya.viswanathan at intel.com> wrote:
> 
> 
> Thanks for adding these. The "species" field access would result in boxing, so generalized intrinsic will have to be at v.add(int) level, possibly leading to expansion to two IR nodes: broadcast followed by operation. By doing expansion at IR level, the broadcast will then be moved out of loop by existing compiler optimizations.
> 
> It will be very interesting to get Vladimir's thought on this.
> 
> Best Regards,
> Sandhya
> 


More information about the panama-dev mailing list