mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16: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() {
|
||||
// TODO: repair CommonSubexpressionElimination and get it back here
|
||||
return Arrays.<MethodOptimization>asList(new UnusedVariableElimination());
|
||||
return Arrays.<MethodOptimization>asList(new GlobalValueNumbering(), new UnusedVariableElimination());
|
||||
}
|
||||
|
||||
public void optimizeAll(ListableClassHolderSource classSource) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.teavm.model.util.ProgramUtils;
|
|||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public class CommonSubexpressionElimination implements MethodOptimization {
|
||||
public class GlobalValueNumbering implements MethodOptimization {
|
||||
private Map<String, KnownValue> knownValues = new HashMap<>();
|
||||
private boolean eliminate;
|
||||
private int[] map;
|
||||
|
@ -137,7 +137,7 @@ public class CommonSubexpressionElimination implements MethodOptimization {
|
|||
|
||||
private void bind(int var, String 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;
|
||||
map[var] = known.value;
|
||||
} else {
|
Loading…
Reference in New Issue
Block a user