LoopNest::sliceTail(loops[0], 4, &head, &tail);
ASSERT_NE(head, nullptr);
- ASSERT_NE(head, loops[0]);
+ ASSERT_EQ(head, loops[0]);
ASSERT_NE(tail, nullptr);
ASSERT_NE(tail, loops[0]);
ExprPtr tail_start = alloc<Max>(
f->start(), alloc<Sub>(f->stop(), alloc<IntImm>(factor)), true);
- *head = alloc<For>(
- f->var(),
- f->start(),
- tail_start,
- Stmt::clone(f->body()),
- f->loop_options());
*tail = alloc<For>(f->var(), tail_start, f->stop(), Stmt::clone(f->body()));
+ p->insert_stmt_after(*tail, f);
- p->replace_stmt(f, *head);
- p->insert_stmt_after(*tail, *head);
+ f->set_stop(tail_start);
+ *head = f;
if (f->loop_options().is_gpu_block_index() ||
f->loop_options().is_gpu_thread_index()) {