Skip to content

Revise loop_conrtol and replace grant_always operations#100

Merged
ShangkunLi merged 10 commits intocoredac:mainfrom
ShangkunLi:revise-loop-control
Jul 31, 2025
Merged

Revise loop_conrtol and replace grant_always operations#100
ShangkunLi merged 10 commits intocoredac:mainfrom
ShangkunLi:revise-loop-control

Conversation

@ShangkunLi
Copy link
Copy Markdown
Collaborator

This pr is the combination and revised version of the previous two not-merged prs:

  • Replace the grant_always with grant_once in --transform-ctrl-to-data-flow
  • Provide a new definition of the loop_control operator. Now, we can fully remove the recurrence dependency brought by loop control operations
  • We add grant_always for end_val and step_val in loop_control. And we can fuse constant into grant_once and grant_always respectively.

@ShangkunLi ShangkunLi marked this pull request as ready for review July 31, 2025 02:04
@ShangkunLi ShangkunLi requested a review from tancheng July 31, 2025 03:26
@ShangkunLi
Copy link
Copy Markdown
Collaborator Author

Add the test for simple loop without reduction dependency.

Before fuse:

module {
  func.func @_Z11simple_loopPiS_(%arg0: memref<?xi32>, %arg1: memref<?xi32>) attributes {CompiledII = 7 : i32, RecMII = 4 : i32, ResMII = 2 : i32, accelerator = "neura", llvm.linkage = #llvm.linkage<external>} {
    %0 = "neura.constant"() <{predicate = true, value = "%arg0"}> {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 0 : i32}]} : () -> !neura.data<memref<?xi32>, i1>
    %1 = "neura.data_mov"(%0) {mapping_locs = [{id = 6 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %2 = "neura.grant_once"(%1) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %3 = "neura.constant"() <{predicate = true, value = "%arg1"}> {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data<memref<?xi32>, i1>
    %4 = "neura.data_mov"(%3) {mapping_locs = [{id = 36 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %5 = "neura.grant_once"(%4) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %6 = "neura.constant"() <{predicate = true, value = 1 : i64}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data<i64, i1>
    %7 = "neura.data_mov"(%6) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %8 = "neura.grant_once"(%7) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %9 = "neura.constant"() <{predicate = true, value = 128 : i64}> {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 0 : i32}]} : () -> !neura.data<i64, i1>
    %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 6 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %11 = "neura.grant_once"(%10) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %12 = "neura.constant"() <{predicate = true, value = 1 : i32}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 1 : i32}]} : () -> !neura.data<i32, i1>
    %13 = "neura.data_mov"(%12) {mapping_locs = []} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %14 = "neura.grant_once"(%13) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %15 = "neura.constant"() <{predicate = true, value = 2 : i32}> {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 0 : i32}]} : () -> !neura.data<i32, i1>
    %16 = "neura.data_mov"(%15) {mapping_locs = [{id = 6 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %17 = "neura.grant_once"(%16) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %18 = "neura.constant"() <{predicate = true, value = 0 : i64}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data<i64, i1>
    %19 = "neura.data_mov"(%18) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %20 = "neura.grant_once"(%19) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %21 = neura.reserve : !neura.data<i64, i1>
    %22 = "neura.data_mov"(%11) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1>
    %24 = neura.reserve : !neura.data<i64, i1>
    %25 = "neura.data_mov"(%20) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %26 = "neura.phi"(%24, %25) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1>
    %27 = "neura.data_mov"(%26) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 2 : i32}, {id = 24 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %28 = "neura.data_mov"(%23) {mapping_locs = [{id = 8 : i32, resource = "link", time_step = 2 : i32}, {id = 7 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %29 = "neura.icmp"(%27, %28) <{cmpType = "slt"}> {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i1, i1>
    %30 = "neura.data_mov"(%29) {mapping_locs = []} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %31 = "neura.not"(%30) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 9 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %32 = "neura.data_mov"(%2) {mapping_locs = [{id = 8 : i32, resource = "link", time_step = 3 : i32}, {id = 8 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %33 = "neura.data_mov"(%29) {mapping_locs = [{id = 19 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %34 = neura.grant_predicate %32, %33 {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 0 : i32}]} : !neura.data<memref<?xi32>, i1>, !neura.data<i1, i1> -> !neura.data<memref<?xi32>, i1>
    %35 = "neura.data_mov"(%26) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 2 : i32}, {id = 29 : i32, resource = "link", time_step = 3 : i32}, {id = 14 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %36 = "neura.data_mov"(%29) {mapping_locs = []} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %37 = neura.grant_predicate %35, %36 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data<i64, i1>, !neura.data<i1, i1> -> !neura.data<i64, i1>
    %38 = "neura.data_mov"(%17) {mapping_locs = [{id = 8 : i32, resource = "link", time_step = 4 : i32}, {id = 7 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %39 = "neura.data_mov"(%29) {mapping_locs = []} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %40 = neura.grant_predicate %38, %39 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data<i32, i1>, !neura.data<i1, i1> -> !neura.data<i32, i1>
    %41 = "neura.data_mov"(%14) {mapping_locs = [{id = 23 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %42 = "neura.data_mov"(%29) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 4 : i32}, {id = 32 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %43 = neura.grant_predicate %41, %42 {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data<i32, i1>, !neura.data<i1, i1> -> !neura.data<i32, i1>
    %44 = "neura.data_mov"(%5) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 6 : i32}, {id = 24 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %45 = "neura.data_mov"(%29) {mapping_locs = []} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %46 = neura.grant_predicate %44, %45 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 8 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data<memref<?xi32>, i1>, !neura.data<i1, i1> -> !neura.data<memref<?xi32>, i1>
    %47 = "neura.data_mov"(%8) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %48 = "neura.data_mov"(%29) {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 4 : i32}, {id = 20 : i32, resource = "register", time_step = 5 : i32}, {id = 20 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %49 = neura.grant_predicate %47, %48 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data<i64, i1>, !neura.data<i1, i1> -> !neura.data<i64, i1>
    %50 = "neura.data_mov"(%11) {mapping_locs = [{id = 8 : i32, resource = "link", time_step = 1 : i32}, {id = 9 : i32, resource = "register", time_step = 2 : i32}, {id = 9 : i32, resource = "register", time_step = 3 : i32}, {id = 9 : i32, resource = "register", time_step = 4 : i32}, {id = 9 : i32, resource = "register", time_step = 5 : i32}, {id = 9 : i32, resource = "register", time_step = 6 : i32}, {id = 9 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %51 = "neura.data_mov"(%29) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 4 : i32}, {id = 22 : i32, resource = "link", time_step = 5 : i32}, {id = 8 : i32, resource = "link", time_step = 6 : i32}, {id = 8 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %52 = neura.grant_predicate %50, %51 {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 8 : i32, x = 2 : i32, y = 0 : i32}]} : !neura.data<i64, i1>, !neura.data<i1, i1> -> !neura.data<i64, i1>
    %53 = "neura.data_mov"(%34) {mapping_locs = []} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %54 = "neura.data_mov"(%37) {mapping_locs = [{id = 19 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %55 = neura.load_indexed %53[%54 : !neura.data<i64, i1>] !neura.data<memref<?xi32>, i1> {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 0 : i32}]} : !neura.data<i32, i1>
    %56 = "neura.data_mov"(%55) {mapping_locs = [{id = 7 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %57 = "neura.data_mov"(%40) {mapping_locs = []} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %58 = "neura.mul"(%56, %57) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
    %59 = "neura.data_mov"(%58) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %60 = "neura.data_mov"(%43) {mapping_locs = [{id = 36 : i32, resource = "link", time_step = 6 : i32}, {id = 28 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %61 = "neura.add"(%59, %60) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 8 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
    %62 = "neura.data_mov"(%61) {mapping_locs = []} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %63 = "neura.data_mov"(%46) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %64 = "neura.data_mov"(%37) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 5 : i32}, {id = 29 : i32, resource = "register", time_step = 6 : i32}, {id = 29 : i32, resource = "register", time_step = 7 : i32}, {id = 29 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    neura.store_indexed %62 to %63[%64 : !neura.data<i64, i1>] !neura.data<memref<?xi32>, i1> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 9 : i32, x = 3 : i32, y = 1 : i32}]} : !neura.data<i32, i1>
    %65 = "neura.data_mov"(%37) {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 5 : i32}, {id = 16 : i32, resource = "link", time_step = 6 : i32}, {id = 36 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %66 = "neura.data_mov"(%49) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %67 = "neura.add"(%65, %66) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1>
    neura.ctrl_mov %67 -> %24 {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 8 : i32}]} : !neura.data<i64, i1> !neura.data<i64, i1>
    neura.ctrl_mov %52 -> %21 {mapping_locs = [{id = 6 : i32, resource = "link", time_step = 8 : i32}]} : !neura.data<i64, i1> !neura.data<i64, i1>
    "neura.return"() {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 8 : i32, x = 0 : i32, y = 0 : i32}]} : () -> ()
  }
}

After fuse:

module {
  func.func @_Z11simple_loopPiS_(%arg0: memref<?xi32>, %arg1: memref<?xi32>) attributes {CompiledII = 4 : i32, ResMII = 2 : i32, accelerator = "neura", llvm.linkage = #llvm.linkage<external>} {
    %0 = "neura.constant"() <{predicate = true, value = "%arg0"}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data<memref<?xi32>, i1>
    %1 = "neura.data_mov"(%0) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %2 = "neura.grant_once"(%1) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %3 = "neura.constant"() <{predicate = true, value = "%arg1"}> {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 0 : i32}]} : () -> !neura.data<memref<?xi32>, i1>
    %4 = "neura.data_mov"(%3) {mapping_locs = [{id = 2 : i32, resource = "link", time_step = 4 : i32}, {id = 0 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %5 = "neura.grant_once"(%4) {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 6 : i32, x = 0 : i32, y = 0 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %6 = "neura.constant"() <{predicate = true, value = 1 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data<i64, i1>
    %7 = "neura.constant"() <{predicate = true, value = 128 : i64}> {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data<i64, i1>
    %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %9 = "neura.grant_always"(%8) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %10 = "neura.data_mov"(%6) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %11 = "neura.grant_always"(%10) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %12 = "neura.constant"() <{predicate = true, value = 1 : i32}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data<i32, i1>
    %13 = "neura.data_mov"(%12) {mapping_locs = [{id = 1 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %14 = "neura.grant_once"(%13) {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %15 = "neura.constant"() <{predicate = true, value = 2 : i32}> {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 0 : i32}]} : () -> !neura.data<i32, i1>
    %16 = "neura.data_mov"(%15) {mapping_locs = [{id = 8 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %17 = "neura.grant_once"(%16) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %18 = "neura.constant"() <{predicate = true, value = 0 : i64}> {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data<i64, i1>
    %19 = "neura.data_mov"(%18) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %20 = "neura.grant_once"(%19) {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %21 = "neura.constant"() <{predicate = true, value = true}> {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data<i1, i1>
    %22 = "neura.data_mov"(%21) {mapping_locs = [{id = 37 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %23 = "neura.grant_always"(%22) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %24 = "neura.data_mov"(%23) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 1 : i32}, {id = 45 : i32, resource = "link", time_step = 2 : i32}, {id = 33 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %25 = "neura.data_mov"(%20) {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 1 : i32}, {id = 29 : i32, resource = "link", time_step = 2 : i32}, {id = 14 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %26 = "neura.data_mov"(%9) {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 1 : i32}, {id = 33 : i32, resource = "link", time_step = 2 : i32}, {id = 24 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %27 = "neura.data_mov"(%11) {mapping_locs = [{id = 3 : i32, resource = "link", time_step = 1 : i32}, {id = 7 : i32, resource = "link", time_step = 2 : i32}, {id = 25 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %nextindex, %valid = neura.loop_control(parent_valid = %24, start = %25, end = %26, step = %27) {iterationType = "increment", mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data<i1, i1>, !neura.data<i64, i1>, !neura.data<i64, i1>, !neura.data<i64, i1> -> !neura.data<i64, i1>, !neura.data<i1, i1>
    %28 = "neura.data_mov"(%valid) {mapping_locs = []} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %29 = "neura.not"(%28) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %30 = "neura.data_mov"(%2) {mapping_locs = [{id = 3 : i32, resource = "link", time_step = 2 : i32}, {id = 8 : i32, resource = "register", time_step = 3 : i32}, {id = 8 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %31 = "neura.data_mov"(%valid) {mapping_locs = [{id = 19 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %32 = neura.grant_predicate %30, %31 {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 0 : i32}]} : !neura.data<memref<?xi32>, i1>, !neura.data<i1, i1> -> !neura.data<memref<?xi32>, i1>
    %33 = "neura.data_mov"(%17) {mapping_locs = [{id = 5 : i32, resource = "link", time_step = 3 : i32}, {id = 4 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %34 = "neura.data_mov"(%valid) {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %35 = neura.grant_predicate %33, %34 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data<i32, i1>, !neura.data<i1, i1> -> !neura.data<i32, i1>
    %36 = "neura.data_mov"(%14) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %37 = "neura.data_mov"(%valid) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 4 : i32}, {id = 31 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %38 = neura.grant_predicate %36, %37 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data<i32, i1>, !neura.data<i1, i1> -> !neura.data<i32, i1>
    %39 = "neura.data_mov"(%5) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 6 : i32}, {id = 3 : i32, resource = "link", time_step = 7 : i32}, {id = 6 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %40 = "neura.data_mov"(%valid) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 4 : i32}, {id = 22 : i32, resource = "link", time_step = 5 : i32}, {id = 12 : i32, resource = "register", time_step = 6 : i32}, {id = 12 : i32, resource = "register", time_step = 7 : i32}, {id = 12 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data<i1, i1>) -> !neura.data<i1, i1>
    %41 = neura.grant_predicate %39, %40 {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 9 : i32, x = 3 : i32, y = 0 : i32}]} : !neura.data<memref<?xi32>, i1>, !neura.data<i1, i1> -> !neura.data<memref<?xi32>, i1>
    %42 = "neura.data_mov"(%32) {mapping_locs = [{id = 7 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %43 = "neura.data_mov"(%nextindex) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    %44 = neura.load_indexed %42[%43 : !neura.data<i64, i1>] !neura.data<memref<?xi32>, i1> {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data<i32, i1>
    %45 = "neura.data_mov"(%44) {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %46 = "neura.data_mov"(%35) {mapping_locs = []} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %47 = "neura.mul"(%45, %46) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
    %48 = "neura.data_mov"(%47) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %49 = "neura.data_mov"(%38) {mapping_locs = []} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %50 = "neura.add"(%48, %49) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data<i32, i1>, !neura.data<i32, i1>) -> !neura.data<i32, i1>
    %51 = "neura.data_mov"(%50) {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 8 : i32}, {id = 33 : i32, resource = "link", time_step = 9 : i32}, {id = 26 : i32, resource = "register", time_step = 10 : i32}, {id = 26 : i32, resource = "register", time_step = 11 : i32}, {id = 26 : i32, resource = "register", time_step = 12 : i32}]} : (!neura.data<i32, i1>) -> !neura.data<i32, i1>
    %52 = "neura.data_mov"(%41) {mapping_locs = [{id = 9 : i32, resource = "link", time_step = 9 : i32}, {id = 21 : i32, resource = "link", time_step = 10 : i32}, {id = 27 : i32, resource = "register", time_step = 11 : i32}, {id = 27 : i32, resource = "register", time_step = 12 : i32}]} : (!neura.data<memref<?xi32>, i1>) -> !neura.data<memref<?xi32>, i1>
    %53 = "neura.data_mov"(%nextindex) {mapping_locs = []} : (!neura.data<i64, i1>) -> !neura.data<i64, i1>
    neura.store_indexed %51 to %52[%53 : !neura.data<i64, i1>] !neura.data<memref<?xi32>, i1> {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 13 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data<i32, i1>
    "neura.return"() {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 2 : i32}]} : () -> ()
  }
}

@tancheng tancheng added the new feature New feature or request label Jul 31, 2025
@ShangkunLi ShangkunLi merged commit 7b2b374 into coredac:main Jul 31, 2025
1 check passed
ShangkunLi added a commit that referenced this pull request Mar 12, 2026
Revise loop_conrtol and replace grant_always operations
ShangkunLi added a commit that referenced this pull request Mar 12, 2026
Revise loop_conrtol and replace grant_always operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants