RFR: 8283307: Vectorize unsigned shift right on signed subword types

Fei Gao fgao at openjdk.java.net
Tue Apr 12 02:03:41 UTC 2022


On Mon, 11 Apr 2022 13:54:12 GMT, Jie Fu <jiefu at openjdk.org> wrote:

> However, changing the opcode in superword code seems tricky, which may be not easy to maintain. Why not transform scalar `urhsift` --> `rshift` during the GVN phase like this?

Thanks for your kind advice @DamonFool .

The simple transformation from `urshift` to `rshift` is based on vector operation and limited shift amount as described in comment lines. We can't easily do the replacement from `urshift` to `rshift` in GVN phase. That's because scalar `rshift` on subword types are not equivalent to scalar `urshift` on subword types in Java Spec. In GVN phase, we still have no idea if the current node can be vectorized and have to follow the quite complex rules if we do the transformation, as illustrated here https://docs.oracle.com/javase/specs/jls/se18/html/jls-15.html#jls-15.19.  It would bring extra overhead for all urshift operations on subword types whether they can be vectorized or not.

Besides, when we do the transformation in SLP, the urshift operations on subword types are not always followed by `Store` node and they can be intermediate results. In that case, we can still do the transformation and help vectorize them in SLP phase. But we will miss the opportunity if in GVN phase.

In conclusion, code change in SLP phase seems much easier and can cover more potential scenarios.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7979


More information about the hotspot-compiler-dev mailing list