mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
Repairs common subexpression elimination and renames it to global value
numbering, as it is really pessimistic GVN
This commit is contained in:
parent
4b624d8027
commit
4143e6c8d7
|
@ -36,8 +36,7 @@ public class ClassSetOptimizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MethodOptimization> getOptimizations() {
|
private List<MethodOptimization> getOptimizations() {
|
||||||
// TODO: repair CommonSubexpressionElimination and get it back here
|
return Arrays.<MethodOptimization>asList(new GlobalValueNumbering(), new UnusedVariableElimination());
|
||||||
return Arrays.<MethodOptimization>asList(new UnusedVariableElimination());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void optimizeAll(ListableClassHolderSource classSource) {
|
public void optimizeAll(ListableClassHolderSource classSource) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.teavm.model.util.ProgramUtils;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class CommonSubexpressionElimination implements MethodOptimization {
|
public class GlobalValueNumbering implements MethodOptimization {
|
||||||
private Map<String, KnownValue> knownValues = new HashMap<>();
|
private Map<String, KnownValue> knownValues = new HashMap<>();
|
||||||
private boolean eliminate;
|
private boolean eliminate;
|
||||||
private int[] map;
|
private int[] map;
|
||||||
|
@ -137,7 +137,7 @@ public class CommonSubexpressionElimination implements MethodOptimization {
|
||||||
|
|
||||||
private void bind(int var, String value) {
|
private void bind(int var, String value) {
|
||||||
KnownValue known = knownValues.get(value);
|
KnownValue known = knownValues.get(value);
|
||||||
if (known != null && domTree.dominates(known.location, currentBlockIndex)) {
|
if (known != null && domTree.dominates(known.location, currentBlockIndex) && known.value != var) {
|
||||||
eliminate = true;
|
eliminate = true;
|
||||||
map[var] = known.value;
|
map[var] = known.value;
|
||||||
} else {
|
} else {
|
Loading…
Reference in New Issue
Block a user