Commit 0de71700 by Tianqi Chen Committed by GitHub

[BUGFIX] Fix CanonicalSimplify change type of int constant (#269)

parent 7e3d9da4
......@@ -127,9 +127,11 @@ jvm/*/*/target/
!default.perspectivev3
xcuserdata/
.emscripten*
.m2
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
.DS_Store
......@@ -113,6 +113,7 @@ struct BinaryExpr {
}
};
template<typename T>
inline Expr Binary_(const T* op,
const Expr& e,
......@@ -282,6 +283,7 @@ class Canonical::Internal : public IRMutator {
}
// IntImm
Expr Mutate_(const IntImm* op, const Expr& e) final {
if (op->type != Int(32)) return e;
auto it = cache_intimm_.find(op->value);
if (it != cache_intimm_.end()) {
return it->second;
......
......@@ -239,17 +239,18 @@ class StoragePlanRewriter : public IRMutator {
const Variable* buffer = op->args[1].as<Variable>();
auto it = alloc_map_.find(buffer);
if (it == alloc_map_.end()) return IRMutator::Mutate_(op, e);
const StorageEntry* e = it->second;
const StorageEntry* se = it->second;
Expr offset = Mutate(op->args[2]);
Expr extent = Mutate(op->args[3]);
CHECK_EQ(e->elem_type, dtype.element_of());
CHECK_EQ(e->elem_offset % dtype.lanes(), 0);
if (e->elem_offset != 0) {
offset = make_const(offset.type(), e->elem_offset / dtype.lanes()) + offset;
CHECK_EQ(se->elem_type, dtype.element_of())
<< " buffer=" << buffer->name_hint;
CHECK_EQ(se->elem_offset % dtype.lanes(), 0);
if (se->elem_offset != 0) {
offset = make_const(offset.type(), se->elem_offset / dtype.lanes()) + offset;
}
return Call::make(
op->type, op->name,
{op->args[0], e->alloc_var, offset, extent, op->args[4]},
{op->args[0], se->alloc_var, offset, extent, op->args[4]},
op->call_type);
} else {
return IRMutator::Mutate_(op, e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment