Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline loops that we know will only execute once #136

Open
superlopuh opened this issue Jan 9, 2024 · 0 comments
Open

inline loops that we know will only execute once #136

superlopuh opened this issue Jan 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@superlopuh
Copy link
Collaborator

superlopuh commented Jan 9, 2024

This should help us run the conv and pooling kernels as they have multiple 1-dim loops each.

MWE(?) as filecheck test:

// RUN: xdsl-opt -p canonicalize %s | filecheck %s

riscv_func.func @at_least_once() {
    %one = riscv.li 1 : () -> !riscv.reg<>
    %three = riscv.li 3 : () -> !riscv.reg<>
    %0 = riscv.mv %one : (!riscv.reg<>) -> !riscv.reg<>
    riscv_cf.bge %0 : !riscv.reg<>, %three : !riscv.reg<>, ^0(%0 : !riscv.reg<>), ^1(%0 : !riscv.reg<>)
^1(%i : !riscv.reg<>):
    riscv.label "scf_body_0_for"
    "test.op"(%i) : (!riscv.reg<>) -> ()
    %1 = riscv.add %i, %one : (!riscv.reg<>, !riscv.reg<>) -> !riscv.reg<>
    riscv_cf.blt %1 : !riscv.reg<>, %three : !riscv.reg<>, ^1(%1 : !riscv.reg<>), ^0(%1 : !riscv.reg<>)
^0(%2 : !riscv.reg<>):
    riscv.label "scf_body_end_0_for"
    riscv_func.return
}

// CHECK-NEXT:    riscv_func.func @at_least_once() {
// CHECK-NEXT:      %one = riscv.li 1 : () -> !riscv.reg<>
// CHECK-NEXT:      %three = riscv.li 3 : () -> !riscv.reg<>
// CHECK-NEXT:      %0 = riscv.mv %one : (!riscv.reg<>) -> !riscv.reg<>
// CHECK-NEXT:    riscv_cf.branch ^1(%0 : !riscv.reg<>)
// CHECK-NEXT:    ^1(%i : !riscv.reg<>):
// CHECK-NEXT:      riscv.label "scf_body_0_for"
// CHECK-NEXT:      "test.op"(%i) : (!riscv.reg<>) -> ()
// CHECK-NEXT:      %1 = riscv.add %i, %one : (!riscv.reg<>, !riscv.reg<>) -> !riscv.reg<>
// CHECK-NEXT:      riscv_cf.blt %1 : !riscv.reg<>, %three : !riscv.reg<>, ^1(%1 : !riscv.reg<>), ^0(%1 : !riscv.reg<>)
// CHECK-NEXT:    ^0(%2 : !riscv.reg<>):
// CHECK-NEXT:      riscv.label "scf_body_end_0_for"
// CHECK-NEXT:      riscv_func.return
// CHECK-NEXT:    }
@compor compor self-assigned this Jan 12, 2024
@compor compor added the enhancement New feature or request label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants