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/ ...@@ -127,9 +127,11 @@ jvm/*/*/target/
!default.perspectivev3 !default.perspectivev3
xcuserdata/ xcuserdata/
.emscripten*
.m2
## Other ## Other
*.moved-aside *.moved-aside
*.xccheckout *.xccheckout
*.xcscmblueprint *.xcscmblueprint
.DS_Store .DS_Store
...@@ -113,6 +113,7 @@ struct BinaryExpr { ...@@ -113,6 +113,7 @@ struct BinaryExpr {
} }
}; };
template<typename T> template<typename T>
inline Expr Binary_(const T* op, inline Expr Binary_(const T* op,
const Expr& e, const Expr& e,
...@@ -282,6 +283,7 @@ class Canonical::Internal : public IRMutator { ...@@ -282,6 +283,7 @@ class Canonical::Internal : public IRMutator {
} }
// IntImm // IntImm
Expr Mutate_(const IntImm* op, const Expr& e) final { Expr Mutate_(const IntImm* op, const Expr& e) final {
if (op->type != Int(32)) return e;
auto it = cache_intimm_.find(op->value); auto it = cache_intimm_.find(op->value);
if (it != cache_intimm_.end()) { if (it != cache_intimm_.end()) {
return it->second; return it->second;
......
...@@ -239,17 +239,18 @@ class StoragePlanRewriter : public IRMutator { ...@@ -239,17 +239,18 @@ class StoragePlanRewriter : public IRMutator {
const Variable* buffer = op->args[1].as<Variable>(); const Variable* buffer = op->args[1].as<Variable>();
auto it = alloc_map_.find(buffer); auto it = alloc_map_.find(buffer);
if (it == alloc_map_.end()) return IRMutator::Mutate_(op, e); 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 offset = Mutate(op->args[2]);
Expr extent = Mutate(op->args[3]); Expr extent = Mutate(op->args[3]);
CHECK_EQ(e->elem_type, dtype.element_of()); CHECK_EQ(se->elem_type, dtype.element_of())
CHECK_EQ(e->elem_offset % dtype.lanes(), 0); << " buffer=" << buffer->name_hint;
if (e->elem_offset != 0) { CHECK_EQ(se->elem_offset % dtype.lanes(), 0);
offset = make_const(offset.type(), e->elem_offset / dtype.lanes()) + offset; if (se->elem_offset != 0) {
offset = make_const(offset.type(), se->elem_offset / dtype.lanes()) + offset;
} }
return Call::make( return Call::make(
op->type, op->name, 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); op->call_type);
} else { } else {
return IRMutator::Mutate_(op, e); 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