-
Notifications
You must be signed in to change notification settings - Fork 175
[CIR][ThroughMLIR] Lower WhileOp with break. #1942
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -emit-mlir=core %s -o %t.mlir | ||
| // RUN: FileCheck --input-file=%t.mlir %s | ||
|
|
||
| void while_break() { | ||
| int i = 0; | ||
| while (i < 100) { | ||
| i++; | ||
| break; | ||
| i++; | ||
| } | ||
| // This should be compiled into the condition `i < 100` and a single `i++`, | ||
bcardosolopes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // without the while-loop. | ||
|
|
||
| // CHECK: memref.alloca_scope { | ||
| // CHECK: %[[IV:.+]] = memref.load %alloca[] | ||
| // CHECK: %[[HUNDRED:.+]] = arith.constant 100 | ||
| // CHECK: %[[_:.+]] = arith.cmpi slt, %[[IV]], %[[HUNDRED]] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was looking at the generated IR and I'm not sure this works right, the loop is gone but you still need to increment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the 2nd while (i < 100) {
i++;
break;
i++;
}There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got that but I'm still not seeing a loop there and I'm curious what's going on |
||
| // CHECK: memref.alloca_scope { | ||
| // CHECK: %[[IV2:.+]] = memref.load %alloca[] | ||
| // CHECK: %[[ONE:.+]] = arith.constant 1 | ||
| // CHECK: %[[INCR:.+]] = arith.addi %[[IV2]], %[[ONE]] | ||
| // CHECK: memref.store %[[INCR]], %alloca[] | ||
| // CHECK: } | ||
| // CHECK: } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.