C2 SuperWord: improve subword vectorization, avoid cast to-and-from int

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 27
    • Component/s: hotspot

      With JDK-8342095, we now have casts to-and-from subword/int. That unlocked vectorization of quite a few subword operations. But since C2 scalar ops are then all done in int, we cast from subword->int, then do int ops, then cast back int->subword. In scalar code, this is fine, it all uses one scalar register anyway.

      But for vectorization, the cast subword->int means a factor loss of 2 or 4, because we must accomodate int lanes, and so the byte/short/char vectors cannot use full vectors.

      While JDK-8342095 at least uses int-vector-ops, we could probably optimize many of these cases by removing the casts and doing the ops in subword type, at least as long as truncation is allowed. We already do that for some cases, so I don't exactly know what blocks the others discovered in JDK-8342095.

      We should investigate and see what could be done. I don't know if the solutions would be very simple, because we may have to modify the graph already before packing, so that we don't get any int-packs, and don't split the packs. Maybe we'd have to already pack the C2 graph into a scalar VTransform right at the beginning of SuperWord, and then optimize the scalar VTransform, then do SuperWord packing on that scalar VTransform, then generate a vector VTransform. Just an idea for now. But the scalar VTransform would also be useful for other purposes (e.g. if-conversion JDK-8347116), so maybe the idea is not so crazy ;)

            Assignee:
            Unassigned
            Reporter:
            Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: