Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-hitonami committed Feb 18, 2024
1 parent f448b35 commit 231e395
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 0 additions & 7 deletions taichi/transforms/alg_simp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,6 @@ class AlgSimp : public BasicStmtVisitor {
modifier.mark_as_modified();
}
}
} else if (stmt->op_type == UnaryOpType::abs) {
auto operand_type = stmt->operand->ret_type;
if (is_integral(operand_type) && is_unsigned(operand_type)) {
// abs(u) -> u
stmt->replace_usages_with(stmt->operand);
modifier.erase(stmt);
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions taichi/transforms/simplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ class BasicBlockSimplify : public IRVisitor {
}
}

void visit(UnaryOpStmt *stmt) override {
if (stmt->op_type == UnaryOpType::abs) {
auto operand_type = stmt->operand->ret_type;
if (is_integral(operand_type) && is_unsigned(operand_type)) {
// abs(u) -> u
stmt->replace_usages_with(stmt->operand);
modifier.erase(stmt);
}
}
}
template <typename T>
static bool identical_vectors(const std::vector<T> &a,
const std::vector<T> &b) {
Expand Down

0 comments on commit 231e395

Please sign in to comment.