RFR: 8256823: C2 compilation fails with "assert(isShiftCount(imm8 >> 1)) failed: illegal shift count"
Vladimir Ivanov
vlivanov at openjdk.java.net
Mon Nov 23 14:14:59 UTC 2020
On Mon, 23 Nov 2020 13:26:30 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
> The ideal transformation added by [JDK-8254872](https://bugs.openjdk.java.net/browse/JDK-8254872) converts `RotateLeftNode(val, shift)` into `RotateRightNode(val, 32/64 - (shift & 31/63))`. If `shift` later becomes zero, we end up trying to emit a rotate with a 32/64 shift value which triggers an assert.
>
> I've added an identity transformation similar to what is implemented for ShiftNodes that takes care of this. I've also noticed that the corresponding assert is not strong enough for `roll` and `rorl` (probably the author used the assert corresponding to the 64-bit version by accident). The patch also includes some refactoring.
>
> Thanks,
> Tobias
Overall, looks good.
Some minor comments follow.
src/hotspot/share/opto/mulnode.cpp line 1450:
> 1448: }
> 1449: // Rotate by a multiple of 32/64 does nothing
> 1450: int mask = (t1->isa_int() ? BitsPerJavaInteger : BitsPerJavaLong) - 1;
Would be nice to assert that t1 is either TypeInt or TypeLong.
src/hotspot/share/opto/mulnode.cpp line 1451:
> 1449: // Rotate by a multiple of 32/64 does nothing
> 1450: int mask = (t1->isa_int() ? BitsPerJavaInteger : BitsPerJavaLong) - 1;
> 1451: if ((getShiftCon(phase, this, -1) & mask) == 0) {
I find the interaction between `in(2)`, `-1`, and `& mask == 0` intricate (it covers both cases: when shift constant is successfully extracted and when it is not).
Maybe refactor `getShiftCon()` to return a `bool` which signals that the constant was found and then return the value as an out argument?
-------------
PR: https://git.openjdk.java.net/jdk/pull/1384
More information about the hotspot-compiler-dev
mailing list