Commit f51d6337 authored by Skylot's avatar Skylot

Inline all literal constants (not only boolean)

parent bca90c1f
...@@ -26,7 +26,7 @@ public class ConstInlinerVisitor extends AbstractVisitor { ...@@ -26,7 +26,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
return; return;
for (BlockNode block : mth.getBasicBlocks()) { for (BlockNode block : mth.getBasicBlocks()) {
for (Iterator<InsnNode> it = block.getInstructions().iterator(); it.hasNext();) { for (Iterator<InsnNode> it = block.getInstructions().iterator(); it.hasNext(); ) {
InsnNode insn = it.next(); InsnNode insn = it.next();
if (checkInsn(mth, block, insn)) if (checkInsn(mth, block, insn))
it.remove(); it.remove();
...@@ -39,12 +39,8 @@ public class ConstInlinerVisitor extends AbstractVisitor { ...@@ -39,12 +39,8 @@ public class ConstInlinerVisitor extends AbstractVisitor {
if (insn.getArgsCount() == 1 if (insn.getArgsCount() == 1
&& insn.getArg(0).isLiteral() && insn.getArg(0).isLiteral()
&& insn.getResult().getType().getRegCount() == 1 /* process only narrow types */) { && insn.getResult().getType().getRegCount() == 1 /* process only narrow types */) {
// literal arg long lit = ((LiteralArg) insn.getArg(0)).getLiteral();
LiteralArg litArg = (LiteralArg) insn.getArg(0); return replaceConst(mth, block, insn, lit);
long lit = litArg.getLiteral();
if (lit == 0 || lit == 1) {
return replaceConst(mth, block, insn, lit);
}
} }
// TODO process string const // TODO process string const
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment