Skip to content

Commit

Permalink
Remove excessive checks from DifferentiateLoopBody.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Jan 18, 2024
1 parent b388bec commit fb30527
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3295,19 +3295,12 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
}
addToCurrentBlock(condDiff.getStmt_dx(), direction::reverse);
bodyDiff = Visit(body);
if (auto* bodyCS = dyn_cast<CompoundStmt>(bodyDiff.getStmt()))
for (Stmt* S : bodyCS->body())
addToCurrentBlock(S, direction::forward);
else
addToCurrentBlock(bodyDiff.getStmt(), direction::forward);
if (bodyDiff.getStmt_dx()) {
if (auto* bodyDxCS = dyn_cast<CompoundStmt>(bodyDiff.getStmt_dx()))
for (auto iter = bodyDxCS->body_rbegin(), e = bodyDxCS->body_rend();
iter != e; ++iter)
addToCurrentBlock(*iter, direction::reverse);
else
addToCurrentBlock(bodyDiff.getStmt_dx(), direction::reverse);
}
for (Stmt* S : cast<CompoundStmt>(bodyDiff.getStmt())->body())
addToCurrentBlock(S, direction::forward);
auto* bodyDxCS = cast<CompoundStmt>(bodyDiff.getStmt_dx());
for (auto iter = bodyDxCS->body_rbegin(), e = bodyDxCS->body_rend();
iter != e; ++iter)
addToCurrentBlock(*iter, direction::reverse);
addToCurrentBlock(forLoopIncDiff, direction::reverse);
bodyDiff.updateStmt(endBlock(direction::forward));
bodyDiff.updateStmtDx(unwrapIfSingleStmt(endBlock(direction::reverse)));
Expand Down

0 comments on commit fb30527

Please sign in to comment.