Fold I2L with ICONST_n when beneficial

ICONST_0; I2L -> LCONST_0
ICONST_1; I2L -> LCONST_1
This commit is contained in:
Dmitry Petrov
2017-07-07 13:45:55 +03:00
parent ad80c3cd7f
commit aa7db727ba
5 changed files with 19 additions and 4 deletions
@@ -65,6 +65,19 @@ class StackPeepholeOptimizationsTransformer : MethodTransformer() {
}
}
Opcodes.I2L -> {
when (prevNonNop.opcode) {
Opcodes.ICONST_0 -> actions.add {
it.remove(insn)
it.set(prevNonNop, InsnNode(Opcodes.LCONST_0))
}
Opcodes.ICONST_1 -> actions.add {
it.remove(insn)
it.set(prevNonNop, InsnNode(Opcodes.LCONST_1))
}
}
}
Opcodes.POP2 -> {
if (prevNonNop.isEliminatedByPop2()) {
actions.add {