[Mlir-commits] [mlir] Allow SymbolUserOpInterface operators to be used in RemoveDeadValues Pass (PR #117405)
M. Zeeshan Siddiqui
llvmlistbot at llvm.org
Sat Nov 23 10:07:59 PST 2024
================
@@ -577,10 +577,8 @@ void RemoveDeadValues::runOnOperation() {
WalkResult acceptableIR = module->walk([&](Operation *op) {
if (op == module)
return WalkResult::advance();
- if (isa<BranchOpInterface>(op) ||
- (isa<SymbolUserOpInterface>(op) && !isa<CallOpInterface>(op))) {
- op->emitError() << "cannot optimize an IR with "
- "non-call symbol user ops or branch ops\n";
+ if (isa<BranchOpInterface>(op)) {
----------------
codemzs wrote:
PASSES:
```
// Dead values are removed from the IR.
//
func.func @test_branch_op(%arg0: memref<i32>, %arg1: memref<i32>, %arg2: i1) {
%c0_i32 = arith.constant 0 : i32
// CHECK-NOT: %non_live = arith.constant
%non_live = arith.constant 0 : i32
cf.cond_br %arg2, ^bb1(%c0_i32 : i32), ^bb2(%c0_i32 : i32) {tag = "br"}
^bb1(%0 : i32):
memref.store %0, %arg0[] : memref<i32>
cf.br ^bb3
^bb2(%1 : i32):
memref.store %1, %arg1[] : memref<i32>
cf.br ^bb3
^bb3:
return
}
```
@joker-eph @parsifal-47 My concern here is if the user gives an IR where removing a dead value will result in a crash then is that an acceptable outcome? If it is then I can remove this condition and add the above test but if this scenario needs to be handled more gracefully then I will prefer we make it as a separate change. Thoughts?
https://github.com/llvm/llvm-project/pull/117405
More information about the Mlir-commits
mailing list