C2: Missed Ideal optimization opportunity in PhaseIterGVN for URShiftI and LShiftI

XMLWordPrintable

      URShiftINode::Ideal uses phase->type(shl->in(2)) == t2 to check if LShift and URShift have matching shift counts. During IGVN, mask_and_replace_shift_amount normalizes shift counts (e.g., -1 -> 31), but LShift and URShift may be processed at different times, leaving them with different constant nodes for the same effective count. The type pointer comparison then fails and the (X << C) >>> C -> X & mask optimization is missed.

      URShiftLNode affected too. Same root cause as JDK-8374798.

      repro: java -XX:+StressIGVN -XX:+StressCCP -XX:VerifyIterativeGVN=0100 -Xcomp -XX:-TieredCompilation -XX:CompileCommand=compileonly,*URShiftOpt*::mainTest* URShiftOpt.java

            Assignee:
            Kerem Kat
            Reporter:
            Kerem Kat
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: