Skip to content

Commit

Permalink
make use of VecStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Aug 28, 2020
1 parent 42317f8 commit daa264b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
2 changes: 0 additions & 2 deletions taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,9 @@ void export_lang(py::module &m) {
m.def("host_arch", host_arch);

m.def("set_lib_dir", [&](const std::string &dir) {
TI_INFO("set_lib_dir: [{}]", dir);
compiled_lib_dir = dir;
});
m.def("set_tmp_dir", [&](const std::string &dir) {
TI_INFO("set_tmp_dir: [{}]", dir);
runtime_tmp_dir = dir;
});
m.def("get_runtime_dir", get_runtime_dir);
Expand Down
33 changes: 14 additions & 19 deletions taichi/transforms/demote_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,23 @@ class DemoteOperations : public BasicStmtVisitor {
if (stmt->get_kernel()->program.config.async_mode)
return;

auto one = Stmt::make<ConstStmt>(LaneAttribute<TypedConstant>(1));
auto begin = Stmt::make<ConstStmt>(LaneAttribute<TypedConstant>(
VecStatement statements;
auto one = statements.push_back<ConstStmt>(LaneAttribute<TypedConstant>(1));
auto begin = statements.push_back<ConstStmt>(LaneAttribute<TypedConstant>(
stmt->bit_begin));
auto esbeg = Stmt::make<ConstStmt>(LaneAttribute<TypedConstant>(
auto esbeg = statements.push_back<ConstStmt>(LaneAttribute<TypedConstant>(
stmt->bit_end - stmt->bit_begin));
auto input_sar_begin = Stmt::make<BinaryOpStmt>(BinaryOpType::bit_sar,
stmt->input, begin.get());
auto one_shl_esbeg = Stmt::make<BinaryOpStmt>(BinaryOpType::bit_shl,
one.get(), esbeg.get());
auto one_shl_esbeg_sub_one = Stmt::make<BinaryOpStmt>(BinaryOpType::sub,
one_shl_esbeg.get(), one.get());
auto ret = Stmt::make<BinaryOpStmt>(BinaryOpType::bit_and,
input_sar_begin.get(), one_shl_esbeg_sub_one.get());
auto input_sar_begin = statements.push_back<BinaryOpStmt>(
BinaryOpType::bit_sar, stmt->input, begin);
auto one_shl_esbeg = statements.push_back<BinaryOpStmt>(
BinaryOpType::bit_shl, one, esbeg);
auto one_shl_esbeg_sub_one = statements.push_back<BinaryOpStmt>(
BinaryOpType::sub, one_shl_esbeg, one);
auto ret = statements.push_back<BinaryOpStmt>(
BinaryOpType::bit_and, input_sar_begin, one_shl_esbeg_sub_one);

stmt->replace_with(ret.get());
modifier.insert_before(stmt, std::move(one));
modifier.insert_before(stmt, std::move(begin));
modifier.insert_before(stmt, std::move(esbeg));
modifier.insert_before(stmt, std::move(input_sar_begin));
modifier.insert_before(stmt, std::move(one_shl_esbeg));
modifier.insert_before(stmt, std::move(one_shl_esbeg_sub_one));
modifier.insert_before(stmt, std::move(ret));
stmt->replace_with(ret);
modifier.insert_before(stmt, std::move(statements));
modifier.erase(stmt);
}

Expand Down

0 comments on commit daa264b

Please sign in to comment.