diff --git a/src/arithmetic/detect_linear_equation.cc b/src/arithmetic/detect_linear_equation.cc index 63f582160312..642a866866d2 100644 --- a/src/arithmetic/detect_linear_equation.cc +++ b/src/arithmetic/detect_linear_equation.cc @@ -123,25 +123,28 @@ class LinearEqDetector }; Array DetectLinearEquation(const Expr& e, const Array& vars) { - CHECK_GE(vars.size(), 1U); Expr base = e; Array coeff; - for (Var v : vars) { - LinearEqEntry ret; - if (!LinearEqDetector(v).Detect(base, &ret)) { - return Array(); + if (0 == vars.size()) { + coeff.push_back(make_const(Int(32), 1)); + } else { + for (Var v : vars) { + LinearEqEntry ret; + if (!LinearEqDetector(v).Detect(base, &ret)) { + return Array(); + } + coeff.push_back(ret.coeff); + base = std::move(ret.base); } - coeff.push_back(ret.coeff); - base = std::move(ret.base); - } - std::unordered_set vset; - for (size_t i = vars.size(); i != 1; --i) { - vset.insert(vars[i - 1].get()); - // The previous coeff contains the variable - if (ExprUseVar(coeff[i - 2], vset)) { - return Array(); + std::unordered_set vset; + for (size_t i = vars.size(); i != 1; --i) { + vset.insert(vars[i - 1].get()); + // The previous coeff contains the variable + if (ExprUseVar(coeff[i - 2], vset)) { + return Array(); + } } } coeff.push_back(base); diff --git a/src/pass/inject_copy_intrin.cc b/src/pass/inject_copy_intrin.cc index cafcddcb9dde..ba44253a0cd5 100644 --- a/src/pass/inject_copy_intrin.cc +++ b/src/pass/inject_copy_intrin.cc @@ -40,6 +40,7 @@ class CopyIntrinInjector : public IRMutator { private: bool MatchCopyPattern(Stmt stmt, Stmt *out) { Stmt body = stmt; + bool is_single_point_copy = false; // strip the loops std::vector loops; @@ -53,7 +54,10 @@ class CopyIntrinInjector : public IRMutator { const Select* select = store->value.as