Browse Source

When conditional does not have any common reachable nodes, create only 'true' body. 'False' body is then implicitly the code after the conditional.

pull/1/head^2
David Srbecký 18 years ago
parent
commit
cefcba99d1
  1. 152
      bin/Debug/output.cs
  2. 2
      src/ControlFlow/Node-Optimize.cs

152
bin/Debug/output.cs

@ -285,22 +285,19 @@ namespace Reversi
} }
if (!((@this.squares).Get(row, k) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(row, k) != (IL__ldsfld(Empty)))) {
V_3 = 1; V_3 = 1;
goto BasicBlock_401;
}
if (!((@this.squares).Get(row, k) != i)) {
if (!((@this.safeDiscs).Get(row, k))) {
goto BasicBlock_400;
}
} }
else { else {
goto BasicBlock_400; if (!((@this.squares).Get(row, k) != i)) {
if (!((@this.safeDiscs).Get(row, k))) {
}
else {
goto BasicBlock_401;
}
}
V_5 = 1;
} }
BasicBlock_401: BasicBlock_401:
k = (k + 1); k = (k + 1);
continue;
BasicBlock_400:
V_5 = 1;
goto BasicBlock_401;
} }
else { else {
break; break;
@ -314,22 +311,19 @@ namespace Reversi
} }
if (!((@this.squares).Get(row, k) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(row, k) != (IL__ldsfld(Empty)))) {
V_4 = 1; V_4 = 1;
goto BasicBlock_410;
}
if (!((@this.squares).Get(row, k) != i)) {
if (!((@this.safeDiscs).Get(row, k))) {
goto BasicBlock_409;
}
} }
else { else {
goto BasicBlock_409; if (!((@this.squares).Get(row, k) != i)) {
if (!((@this.safeDiscs).Get(row, k))) {
}
else {
goto BasicBlock_410;
}
}
V_6 = 1;
} }
BasicBlock_410: BasicBlock_410:
k = (k + 1); k = (k + 1);
continue;
BasicBlock_409:
V_6 = 1;
goto BasicBlock_410;
} }
else { else {
break; break;
@ -366,22 +360,19 @@ namespace Reversi
} }
if (!((@this.squares).Get(j, col) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(j, col) != (IL__ldsfld(Empty)))) {
V_3 = 1; V_3 = 1;
goto BasicBlock_426;
}
if (!((@this.squares).Get(j, col) != i)) {
if (!((@this.safeDiscs).Get(j, col))) {
goto BasicBlock_425;
}
} }
else { else {
goto BasicBlock_425; if (!((@this.squares).Get(j, col) != i)) {
if (!((@this.safeDiscs).Get(j, col))) {
}
else {
goto BasicBlock_426;
}
}
V_5 = 1;
} }
BasicBlock_426: BasicBlock_426:
j = (j + 1); j = (j + 1);
continue;
BasicBlock_425:
V_5 = 1;
goto BasicBlock_426;
} }
else { else {
break; break;
@ -395,22 +386,19 @@ namespace Reversi
} }
if (!((@this.squares).Get(j, col) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(j, col) != (IL__ldsfld(Empty)))) {
V_4 = 1; V_4 = 1;
goto BasicBlock_435;
}
if (!((@this.squares).Get(j, col) != i)) {
if (!((@this.safeDiscs).Get(j, col))) {
goto BasicBlock_434;
}
} }
else { else {
goto BasicBlock_434; if (!((@this.squares).Get(j, col) != i)) {
if (!((@this.safeDiscs).Get(j, col))) {
}
else {
goto BasicBlock_435;
}
}
V_6 = 1;
} }
BasicBlock_435: BasicBlock_435:
j = (j + 1); j = (j + 1);
continue;
BasicBlock_434:
V_6 = 1;
goto BasicBlock_435;
} }
else { else {
break; break;
@ -450,23 +438,20 @@ namespace Reversi
} }
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) {
V_3 = 1; V_3 = 1;
goto BasicBlock_451;
}
if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
goto BasicBlock_450;
}
} }
else { else {
goto BasicBlock_450; if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
}
else {
goto BasicBlock_451;
}
}
V_5 = 1;
} }
BasicBlock_451: BasicBlock_451:
j = (j - 1); j = (j - 1);
k = (k - 1); k = (k - 1);
continue;
BasicBlock_450:
V_5 = 1;
goto BasicBlock_451;
} }
else { else {
break; break;
@ -486,23 +471,20 @@ namespace Reversi
} }
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) {
V_4 = 1; V_4 = 1;
goto BasicBlock_461;
}
if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
goto BasicBlock_460;
}
} }
else { else {
goto BasicBlock_460; if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
}
else {
goto BasicBlock_461;
}
}
V_6 = 1;
} }
BasicBlock_461: BasicBlock_461:
j = (j + 1); j = (j + 1);
k = (k + 1); k = (k + 1);
continue;
BasicBlock_460:
V_6 = 1;
goto BasicBlock_461;
} }
else { else {
break; break;
@ -546,23 +528,20 @@ namespace Reversi
} }
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) {
V_3 = 1; V_3 = 1;
goto BasicBlock_478;
}
if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
goto BasicBlock_477;
}
} }
else { else {
goto BasicBlock_477; if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
}
else {
goto BasicBlock_478;
}
}
V_5 = 1;
} }
BasicBlock_478: BasicBlock_478:
j = (j - 1); j = (j - 1);
k = (k + 1); k = (k + 1);
continue;
BasicBlock_477:
V_5 = 1;
goto BasicBlock_478;
} }
else { else {
break; break;
@ -582,23 +561,20 @@ namespace Reversi
} }
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) {
V_4 = 1; V_4 = 1;
goto BasicBlock_488;
}
if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
goto BasicBlock_487;
}
} }
else { else {
goto BasicBlock_487; if (!((@this.squares).Get(j, k) != i)) {
if (!((@this.safeDiscs).Get(j, k))) {
}
else {
goto BasicBlock_488;
}
}
V_6 = 1;
} }
BasicBlock_488: BasicBlock_488:
j = (j + 1); j = (j + 1);
k = (k - 1); k = (k - 1);
continue;
BasicBlock_487:
V_6 = 1;
goto BasicBlock_488;
} }
else { else {
break; break;

2
src/ControlFlow/Node-Optimize.cs

@ -112,7 +112,7 @@ namespace Decompiler.ControlFlow
trueNodes.MoveTo(conditionalNode.TrueBody); trueNodes.MoveTo(conditionalNode.TrueBody);
// We can exit the 'true' part of Loop or MethodBody conviently using 'break' or 'return' // We can exit the 'true' part of Loop or MethodBody conviently using 'break' or 'return'
if (commonReachable.Count > 0 && (conditionalNode.Parent is Loop || conditionalNode.Parent is MethodBodyGraph)) { if (commonReachable.Count > 0) {
Options.NotifyReducingGraph(); Options.NotifyReducingGraph();
falseNodes.MoveTo(conditionalNode.FalseBody); falseNodes.MoveTo(conditionalNode.FalseBody);
} }

Loading…
Cancel
Save