Fix bug in GVN that prevented optimizations in same basic block

This commit is contained in:
Alexey Andreev 2024-10-03 19:36:44 +02:00
parent 2414d74002
commit 8ce104ae64

View File

@ -219,8 +219,7 @@ public class GlobalValueNumbering implements MethodOptimization {
}
namesCompatible = knownName.isEmpty() || name.isEmpty() || knownName.equals(name);
}
if (known != null && domTree.dominates(known.location * 2 + 1, currentBlockIndex * 2) && known.value != var
&& namesCompatible) {
if (known != null && dominates(known.location, currentBlockIndex) && known.value != var && namesCompatible) {
map[var] = known.value;
if (!noReplace) {
replaceMap[var] = known.value;
@ -242,6 +241,10 @@ public class GlobalValueNumbering implements MethodOptimization {
}
}
private boolean dominates(int a, int b) {
return a == b || domTree.dominates(a * 2 + 1, b * 2);
}
private InstructionVisitor constantPreprocessor = new AbstractInstructionVisitor() {
private void setConstant(int index, Number value) {
numericConstants[index] = value;