From b2c78948f57936b5891d747600b18e6e81ea7383 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 27 Mar 2014 21:40:04 +0400 Subject: [PATCH] Loop invariant motion now considers method arguments to be invariants of any loop --- .../main/java/org/teavm/optimization/LoopInvariantMotion.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/teavm-core/src/main/java/org/teavm/optimization/LoopInvariantMotion.java b/teavm-core/src/main/java/org/teavm/optimization/LoopInvariantMotion.java index 786c16897..64e6c26df 100644 --- a/teavm-core/src/main/java/org/teavm/optimization/LoopInvariantMotion.java +++ b/teavm-core/src/main/java/org/teavm/optimization/LoopInvariantMotion.java @@ -46,6 +46,9 @@ public class LoopInvariantMotion implements MethodOptimization { IntegerStack stack = new IntegerStack(graph.size()); int[] defLocation = new int[program.variableCount()]; Arrays.fill(defLocation, -1); + for (int i = 0; i <= method.parameterCount(); ++i) { + defLocation[i] = 0; + } for (int i = 0; i < domGraph.size(); ++i) { if (dom.immediateDominatorOf(i) < 0) { stack.push(i);