Skip to content

Commit

Permalink
Remove unnecessary ifs
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
  • Loading branch information
RRozak committed Jan 12, 2024
1 parent a54d477 commit 47fd9eb
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions src/grt/src/fastroute/src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,19 +575,15 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)
for (l = 0; l < num_layers_; l++) {
for (i = 0; i < num_layers_; i++) {
if (k == 0) {
if (l != i) {
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 2) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 2;
via_link_[i][k] = l;
}
}
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 2) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 2;
via_link_[i][k] = l;
}
} else {
if (l != i) {
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 3) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 3;
via_link_[i][k] = l;
}
}
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 3) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 3;
via_link_[i][k] = l;
}
}
}
}
Expand All @@ -607,12 +603,10 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)

for (l = 0; l < num_layers_; l++) {
for (i = 0; i < num_layers_; i++) {
if (l != i) {
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 1) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 1;
via_link_[i][k] = l;
}
}
}
}

Expand Down Expand Up @@ -696,19 +690,15 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)
for (l = 0; l < num_layers_; l++) {
for (i = 0; i < num_layers_; i++) {
if (k == routelen) {
if (l != i) {
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 2) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 2;
via_link_[i][k] = l;
}
}
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 2) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 2;
via_link_[i][k] = l;
}
} else {
if (l != i) {
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 3) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 3;
via_link_[i][k] = l;
}
}
if (gridD[i][k] > gridD[l][k] + abs(i - l) * 3) {
gridD[i][k] = gridD[l][k] + abs(i - l) * 3;
via_link_[i][k] = l;
}
}
}
}
Expand All @@ -728,12 +718,10 @@ void FastRouteCore::assignEdge(int netID, int edgeID, bool processDIR)

for (l = 0; l < num_layers_; l++) {
for (i = 0; i < num_layers_; i++) {
if (l != i) {
if (gridD[i][0] > gridD[l][0] + abs(i - l) * 1) {
gridD[i][0] = gridD[l][0] + abs(i - l) * 1;
via_link_[i][0] = l;
}
}
if (gridD[i][0] > gridD[l][0] + abs(i - l) * 1) {
gridD[i][0] = gridD[l][0] + abs(i - l) * 1;
via_link_[i][0] = l;
}
}
}

Expand Down

0 comments on commit 47fd9eb

Please sign in to comment.