Comments (8)
Hey, I have unfortunately not found time to tackle this and can give it away. I will note that I did start doing some research unto how do similar canonicalizations look like in scf dialect, and found that they heavily rely on the trivially-unused removal. I would suggest to go a bit deeper there before blindly implementing code that should be handled by core MLIR for us.
My experiments included running mlir-opt
with debug and canonicalization flags on, and ran it on various scf.if
s, scf.execution_region
and similar. I would be happy to see your research results here on how can we have similar behavior for CIR! (Even if the results indicate that we can't use MLIR core to help us). I promise to have shorter turnaround time :)
from clangir.
I may want to tackle this, but I’ll be available to get to it only later this month 🙏🏻🏝️
from clangir.
Thank you for your suggestion. I will research this issue after completing some work related to ThroughMLIR. However, I cannot guarantee that I will be able to solve this issue because I am a newcomer. If there are any updates on this issue, I will post them here promptly. If anyone else is interested in this issue, please feel free to discuss it here.:)
from clangir.
@Kritoooo thanks for following up with this! My workflow suggestion:
- Do one operation at a time.
- Start with the easier ones.
- Start with ones we already handle in MergeCleanups.
- Add new ones.
from clangir.
@orbiri-ns np, I leave this to you (unless someone grabs it first, perhaps unlikely tho)
from clangir.
@orbiri-ns Hello, how is your progress going? If you are too busy, I can do this. Of course, if you have already started, then just ignore my message.
from clangir.
Thank you for your suggestion. I have started moving RemoveRedundantBranches to BrOp::fold. So far, it is going well. However, I have encountered an issue: many original test files do not seem to apply the RemoveRedundantBranches optimization, causing the tests to fail. Do I need to modify all these test files to make them pass? Is there a better way to handle this?
such as CIR/Lowering/loop.cir
origin test
cir.func @forWithBreakTerminatedScopeInBody(%arg0 : !cir.bool) {
cir.for : cond {
cir.condition(%arg0)
} body {
cir.scope { // FIXME(cir): Redundant scope emitted during C codegen.
cir.break
}
cir.yield
} step {
cir.yield
}
cir.return
}
// CHECK: cir.func @forWithBreakTerminatedScopeInBody(%arg0: !cir.bool) {
// CHECK: cir.br ^bb[[#COND:]]
// CHECK: ^bb[[#COND]]:
// CHECK: cir.brcond %arg0 ^bb[[#BODY:]], ^bb[[#EXIT:]]
// CHECK: ^bb[[#BODY]]:
// CHECK: cir.br ^bb[[#EX_SCOPE_IN:]]
// CHECK: ^bb[[#EX_SCOPE_IN]]:
// CHECK: cir.br ^bb[[#EXIT:]]
// CHECK: ^bb[[#EX_SCOPE_EXIT:]]:
// CHECK: cir.br ^bb[[#STEP:]]
// CHECK: ^bb[[#STEP]]:
// CHECK: cir.br ^bb[[#COND:]]
// CHECK: ^bb[[#EXIT]]:
// CHECK: cir.return
// CHECK: }
move RemoveRedundantBranches to BrOp::fold
llvm.func @forWithBreakTerminatedScopeInBody(%arg0: i8) attributes {cir.extra_attrs = #fn_attr} {
llvm.br ^bb1
^bb1: // 2 preds: ^bb0, ^bb3
%0 = llvm.trunc %arg0 : i8 to i1
llvm.cond_br %0, ^bb2, ^bb4
^bb2: // pred: ^bb1
llvm.br ^bb4
^bb3: // no predecessors
llvm.br ^bb1
^bb4: // 2 preds: ^bb1, ^bb2
llvm.return
}
Sure, after moving the RemoveRedundantBranches logic to BrOp::fold, it can directly pass the merge-cleanups.cir test.
from clangir.
You probably need to add -cir-merge-cleanups
to cir-opt
invocation?
from clangir.
Related Issues (20)
- Should use `getCalleeAttr` when lowering `CallOp`
- Should mark private visibility for extern symbols.
- Vector related arith missing `nsw` on addition HOT 2
- Revisit insertion point being restored by an InsertionGuard in `buildSwitchBody()` HOT 1
- [Umbrella] Switch stmt CIRGen issues
- Single-operand vector shuffling HOT 1
- [ThroughMLIR] cir-opt can not work when lowering ForOp to scf HOT 4
- Add a test for arrays of 3-component extended vectors
- Crash with try statement HOT 1
- [GSoC] Add OpenCL support to compile GPU kernels
- Reinstate #668 and #678 HOT 2
- Verify ZdlPv -> ZdlPvm in `test/CIR/CodeGen/dtors.cpp`
- Verify gep uses moving to i64
- Replace uses of `isa`/`dyn_cast`/`cast`/... member functions HOT 2
- Data layout modeling for CIR types
- Add support for `__atomic_thread_fence` HOT 3
- Add canonicalization passes for cir.complex.create
- Problem with emitting MLIR from CIR: `cir.func` gets `dsolocal` attribute HOT 4
- Non-constant memory order in atomic built-ins HOT 3
- Keep higher level abstraction for runtime memory orders on atomics
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clangir.