diff --git a/taichi/transforms/offload.cpp b/taichi/transforms/offload.cpp index 0664467268dfb..ae3a064417368 100644 --- a/taichi/transforms/offload.cpp +++ b/taichi/transforms/offload.cpp @@ -247,26 +247,6 @@ class IdentifyValuesUsedInOtherOffloads : public BasicStmtVisitor { } } - void visit(LocalLoadStmt *stmt) override { - TI_ASSERT(current_offloaded); - TI_ASSERT(stmt->width() == 1); - test_and_allocate(stmt->ptr[0].var); - } - - void visit(LocalStoreStmt *stmt) override { - TI_ASSERT(current_offloaded); - TI_ASSERT(stmt->width() == 1); - test_and_allocate(stmt->ptr); - } - - void visit(AtomicOpStmt *stmt) override { - TI_ASSERT(current_offloaded); - TI_ASSERT(stmt->width() == 1); - if (stmt->dest->is()) { - test_and_allocate(stmt->dest); - } - } - void visit(Stmt *stmt) override { int n_op = stmt->num_operands(); for (int i = 0; i < n_op; i++) { diff --git a/tests/python/test_loops.py b/tests/python/test_loops.py index 80e4d7affca0f..8e7aecc1c4588 100644 --- a/tests/python/test_loops.py +++ b/tests/python/test_loops.py @@ -151,3 +151,23 @@ def test(b: ti.i32, e: ti.i32): test(b, e) for i in range(b, e): assert x[i - b] == i + + +@ti.all_archs +def test_assignment_in_nested_loops(): + # https://github.com/taichi-dev/taichi/issues/1109 + m = ti.var(ti.f32, 3) + x = ti.var(ti.f32, ()) + + @ti.kernel + def func(): + a = x[None] + for i in m: + b = a + for j in range(1): + b = b + x[None] = b + + x[None] = 1 + func() + assert x[None] == 1