Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8330274

C2 SuperWord: VPointer invar: same sum with different addition order should be equal

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 23
    • hotspot

      I have seen a few examples now, where we could know that the invar of two VPointer is identical: the same summands are added up, only in a different order. This means that the invar nodes are not identical. Somtimes there are CastLL between the additions, which further compilcates the comparison.

      I suggest that we recompute the invar for each VPointer as follows:
      take the invar, and traverse all AddP, AddL and CastLL nodes, to find all summands. Then sort the summands by their idx. Then add these up with new AddL nodes. If two VPointer have the same summands, then the sorted list is identical, and the result of the addition with new AddL nodes is also identical. Thus, the final invar can be relied upon to be invariant (no pun intended) to the addition order.

      This optimization seems to be relevant for MemorySegment, where we work with varhandles, which seem to sometimes have different addition orders, or only sometimes have CastLL and sometimes not.

            epeter Emanuel Peter
            epeter Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: