Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlir/lib/Transforms/RemoveDeadValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ static void cleanUpDeadVals(RDVFinalCleanupList &list) {

// 4. Operands
for (auto &o : list.operands) {
o.op->eraseOperands(o.nonLive);
if (o.nonLive.size() > 0)
o.op->eraseOperands(o.nonLive);
}

// 5. Results
Expand Down
22 changes: 22 additions & 0 deletions mlir/test/Transforms/remove-dead-values.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,25 @@ module {
// CHECK: %[[yield:.*]] = arith.addf %{{.*}}, %{{.*}} : f32
// CHECK: linalg.yield %[[yield]] : f32
// CHECK-NOT: arith.subf


// -----

// check that ops with zero operands are correctly handled

module {
func.func @test_zero_operands(%I: memref<10xindex>, %I2: memref<10xf32>) {
%v0 = arith.constant 0 : index
%result = memref.alloca_scope -> index {
%c = arith.addi %v0, %v0 : index
memref.store %c, %I[%v0] : memref<10xindex>
memref.alloca_scope.return %c: index
}
func.return
}
}

// CHECK-LABEL: func @test_zero_operands
// CHECK: memref.alloca_scope
// CHECK: memref.store
// CHECK-NOT: memref.alloca_scope.return
Loading